/* ===== DESIGN TOKENS & CSS VARIABLES ===== */
        :root {
            /* Colors - Dark Theme (Default) */
            --bg-primary: #0d1117;
            --bg-secondary: #161b22;
            --bg-tertiary: #21262d;
            --bg-elevated: #1c2128;
            --border-color: #30363d;
            --border-hover: #484f58;
            --text-primary: #f0f6fc;
            --text-secondary: #8b949e;
            --text-muted: #6e7681;
            --accent-blue: #58a6ff;
            --accent-green: #3fb950;
            --accent-orange: #f0883e;
            --accent-red: #f85149;
            --accent-purple: #a371f7;
            --accent-yellow: #d29922;
            --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
            --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
            --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
            --radius-sm: 6px;
            --radius-md: 10px;
            --radius-lg: 16px;
            --radius-xl: 24px;
            --spacing-xs: 4px;
            --spacing-sm: 8px;
            --spacing-md: 12px;
            --spacing-lg: 16px;
            --spacing-xl: 24px;
            --spacing-2xl: 32px;
            --font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;
            --transition-fast: 150ms ease;
            --transition-base: 250ms ease;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        html, body {
            height: 100%;
            overflow-x: hidden;
        }

        body {
            background: linear-gradient(180deg, #0d1117 0%, #010409 100%);
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
            font-size: 14px;
            line-height: 1.5;
            color: var(--text-primary);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* ===== APP CONTAINER ===== */
        .app-wrapper {
            flex: 1;
            display: flex;
            flex-direction: column;
            padding: var(--spacing-lg);
            max-width: 1920px;
            margin: 0 auto;
            width: 100%;
            gap: var(--spacing-lg);
        }

        .app-container {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-xl);
            padding: var(--spacing-xl);
            box-shadow: var(--shadow-lg);
            display: flex;
            flex-direction: column;
            gap: var(--spacing-xl);
            flex: 1;
            min-height: 0;
        }

        /* ===== HEADER SECTION ===== */
        .app-header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: var(--spacing-lg);
            padding-bottom: var(--spacing-md);
            border-bottom: 1px solid var(--border-color);
            flex-shrink: 0;
        }

        .header-branding {
            display: flex;
            flex-direction: column;
            gap: var(--spacing-xs);
        }

        .app-title {
            font-size: 1.75rem;
            font-weight: 700;
            letter-spacing: -0.02em;
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
        }

        .app-title .icon {
            font-size: 1.5rem;
        }

        .app-subtitle {
            font-size: 0.875rem;
            color: var(--text-secondary);
            font-weight: 400;
        }

        .header-actions {
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
        }

        .info-pill {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: 100px;
            padding: var(--spacing-sm) var(--spacing-md);
            font-size: 0.75rem;
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
            white-space: nowrap;
        }

        .info-pill .divider {
            color: var(--border-color);
        }

        /* ===== MAIN WORKSPACE GRID ===== */
        .workspace {
            display: grid;
            grid-template-columns: 380px 1fr;
            gap: var(--spacing-xl);
            flex: 1;
            min-height: 0;
        }

        /* ===== SIDEBAR / CONTROL PANEL ===== */
        .control-panel {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-lg);
            padding: var(--spacing-lg);
            display: flex;
            flex-direction: column;
            gap: var(--spacing-lg);
            overflow-y: auto;
            max-height: calc(100vh - 220px);
        }

        .panel-section {
            display: flex;
            flex-direction: column;
            gap: var(--spacing-md);
        }

        .panel-section + .panel-section {
            padding-top: var(--spacing-lg);
            border-top: 1px solid var(--border-color);
        }

        .section-header {
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
            font-size: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-muted);
        }

        .section-header .icon {
            font-size: 1rem;
        }

        /* ===== BUTTONS ===== */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: var(--spacing-sm);
            padding: var(--spacing-sm) var(--spacing-md);
            font-size: 0.875rem;
            font-weight: 500;
            border-radius: var(--radius-md);
            border: 1px solid var(--border-color);
            background: var(--bg-elevated);
            color: var(--text-primary);
            cursor: pointer;
            transition: all var(--transition-fast);
            white-space: nowrap;
        }

        .btn:hover {
            background: var(--bg-secondary);
            border-color: var(--border-hover);
        }

        .btn:active {
            transform: translateY(1px);
        }

        .btn-primary {
            background: var(--accent-blue);
            border-color: var(--accent-blue);
            color: #fff;
        }

        .btn-primary:hover {
            background: #79b8ff;
            border-color: #79b8ff;
        }

        .btn-danger {
            background: rgba(248, 81, 73, 0.15);
            border-color: var(--accent-red);
            color: var(--accent-red);
        }

        .btn-danger:hover {
            background: var(--accent-red);
            color: #fff;
        }

        .btn-success {
            background: rgba(63, 185, 80, 0.15);
            border-color: var(--accent-green);
            color: var(--accent-green);
        }

        .btn-success:hover {
            background: var(--accent-green);
            color: #fff;
        }

        .btn-file {
            position: relative;
            overflow: hidden;
        }

        .btn-file input[type="file"] {
            position: absolute;
            inset: 0;
            opacity: 0;
            cursor: pointer;
        }

        .btn-group {
            display: flex;
            flex-wrap: wrap;
            gap: var(--spacing-sm);
        }

        .btn-group-compact {
            display: flex;
            gap: var(--spacing-xs);
        }

        /* ===== FORM ELEMENTS ===== */
        .form-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: var(--spacing-md);
        }

        .form-label {
            font-size: 0.875rem;
            color: var(--text-secondary);
            white-space: nowrap;
        }

        .form-control {
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
            flex: 1;
            justify-content: flex-end;
        }

        select, input[type="range"], input[type="number"] {
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            padding: var(--spacing-sm) var(--spacing-md);
            font-size: 0.875rem;
            color: var(--text-primary);
            outline: none;
            transition: border-color var(--transition-fast);
        }

        select:focus, input[type="number"]:focus {
            border-color: var(--accent-blue);
        }

        select {
            min-width: 140px;
            cursor: pointer;
        }

        input[type="range"] {
            flex: 1;
            min-width: 80px;
            padding: 0;
            height: 4px;
            -webkit-appearance: none;
            background: var(--bg-elevated);
        }

        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--accent-blue);
            cursor: pointer;
            border: 2px solid var(--bg-secondary);
        }

        input[type="number"] {
            width: 70px;
            text-align: center;
            font-family: var(--font-mono);
        }

        .value-display {
            font-family: var(--font-mono);
            font-size: 0.875rem;
            color: var(--text-secondary);
            min-width: 40px;
            text-align: right;
        }

        /* ===== ASPECT RATIO PRESETS ===== */
        .ratio-presets {
            display: flex;
            flex-wrap: wrap;
            gap: var(--spacing-sm);
        }

        .preset-badge {
            display: inline-flex;
            align-items: center;
            gap: var(--spacing-xs);
            padding: var(--spacing-sm) var(--spacing-md);
            background: var(--bg-elevated);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            font-size: 0.8125rem;
            font-weight: 500;
            cursor: pointer;
            transition: all var(--transition-fast);
            color: var(--text-secondary);
        }

        .preset-badge:hover {
            background: var(--bg-secondary);
            border-color: var(--border-hover);
            color: var(--text-primary);
        }

        .preset-badge.active-preset {
            background: rgba(240, 136, 62, 0.15);
            border-color: var(--accent-orange);
            color: var(--accent-orange);
        }

        .custom-ratio-inputs {
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
            flex-wrap: wrap;
        }

        .output-size-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: var(--spacing-sm);
        }

        .size-shortcuts {
            display: flex;
            flex-wrap: wrap;
            gap: var(--spacing-sm);
        }

        .size-shortcuts .btn {
            min-width: 72px;
            padding-inline: 14px;
        }

        .size-shortcuts .btn.is-active {
            background: rgba(88, 166, 255, 0.16);
            border-color: var(--accent-blue);
            color: var(--accent-blue);
        }

        .size-field {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .size-field input[type="number"] {
            width: 100%;
        }

        .custom-ratio-inputs .separator {
            color: var(--text-muted);
            font-weight: 500;
        }

        .hint-text {
            font-size: 0.75rem;
            color: var(--text-muted);
            line-height: 1.4;
        }

        /* ===== CANVAS AREA ===== */
        .canvas-area {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-lg);
            padding: var(--spacing-lg);
            display: flex;
            flex-direction: column;
            gap: var(--spacing-md);
            min-height: 0;
            overflow: hidden;
        }

        .canvas-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-shrink: 0;
        }

        .canvas-title {
            font-size: 0.875rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
        }

        .crop-stats {
            display: flex;
            align-items: center;
            gap: var(--spacing-md);
            font-family: var(--font-mono);
            font-size: 0.8125rem;
            color: var(--text-secondary);
        }

        .crop-stats .stat-item {
            display: flex;
            align-items: center;
            gap: var(--spacing-xs);
            background: var(--bg-primary);
            padding: var(--spacing-xs) var(--spacing-sm);
            border-radius: var(--radius-sm);
        }

        .crop-stage {
            flex: 1;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: var(--spacing-lg);
            position: relative;
            overflow: hidden;
            min-height: 0;
        }

        .crop-stage.empty::before {
            content: 'ðŸ“· Drag & drop images here or use Load button';
            position: absolute;
            color: var(--text-muted);
            font-size: 0.875rem;
            pointer-events: none;
        }

        .image-container {
            position: relative;
            display: inline-block;
            max-width: 100%;
            max-height: 100%;
        }

        #source-img {
            max-width: 100%;
            max-height: 65vh;
            border-radius: var(--radius-sm);
            display: block;
            pointer-events: none;
            box-shadow: var(--shadow-md);
        }

        .crop-canvas {
            position: absolute;
            top: 0;
            left: 0;
            cursor: crosshair;
            border-radius: var(--radius-sm);
        }

        .canvas-footer {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: var(--spacing-md);
            font-size: 0.8125rem;
            color: var(--text-muted);
            flex-shrink: 0;
        }

        .instruction-pill {
            display: inline-flex;
            align-items: center;
            gap: var(--spacing-xs);
            background: var(--bg-primary);
            padding: var(--spacing-xs) var(--spacing-sm);
            border-radius: var(--radius-sm);
            font-size: 0.75rem;
        }

        /* ===== BATCH QUEUE ===== */
        .batch-section {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-lg);
            padding: var(--spacing-lg);
            flex-shrink: 0;
        }

        .batch-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: var(--spacing-md);
        }

        .batch-title {
            font-size: 0.875rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
        }

        .batch-count {
            background: var(--accent-blue);
            color: #fff;
            padding: 2px 8px;
            border-radius: 100px;
            font-size: 0.75rem;
            font-weight: 600;
        }

        .queue-list {
            max-height: 180px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: var(--spacing-xs);
        }

        .queue-list::-webkit-scrollbar {
            width: 6px;
        }

        .queue-list::-webkit-scrollbar-track {
            background: var(--bg-primary);
            border-radius: var(--radius-sm);
        }

        .queue-list::-webkit-scrollbar-thumb {
            background: var(--border-color);
            border-radius: var(--radius-sm);
        }

        .queue-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: var(--spacing-sm) var(--spacing-md);
            background: var(--bg-elevated);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            font-size: 0.8125rem;
        }

        .queue-item-info {
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
        }

        .queue-item-name {
            color: var(--text-primary);
        }

        .queue-empty {
            text-align: center;
            padding: var(--spacing-xl);
            color: var(--text-muted);
            font-size: 0.875rem;
        }

        /* ===== UTILITY ===== */
        .empty-state-icon {
            font-size: 2rem;
            margin-bottom: var(--spacing-sm);
        }
        
        /* Theme overrides */
        body[data-theme="light"] {
            background: linear-gradient(145deg, #eef5ff 0%, #dfeaf7 100%);
            color: #1f2937;
        }

        body[data-theme="light"] .app-container {
            background: rgba(255, 255, 255, 0.76);
            border-color: rgba(148, 163, 184, 0.28);
        }

        body[data-theme="light"] h1 {
            background: linear-gradient(135deg, #0f172a, #2563eb);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }

        body[data-theme="light"] .control-panel,
        body[data-theme="light"] .canvas-area,
        body[data-theme="light"] .batch-section {
            background: rgba(255,255,255,0.72);
            border-color: rgba(148, 163, 184, 0.25);
            color: #111827;
        }
        
        body[data-theme="light"] .crop-stage {
            background: #f8fafc;
        }
        
        body[data-theme="light"] .ratio-presets {
            background: rgba(0,0,0,0.04);
        }
        
        body[data-theme="light"] .preset-badge {
            background: #e2e8f0;
            color: #0f172a;
            border-color: #b9c7d9;
        }
        
        body[data-theme="light"] .preset-badge.active-preset {
            background: #f59e0b;
            color: white;
            border-color: #d97706;
        }
        
        body[data-theme="light"] .queue-item {
            background: #eef4fb;
        }
        
        body[data-theme="light"] button,
        body[data-theme="light"] .file-label,
        body[data-theme="light"] select,
        body[data-theme="light"] input {
            background: #ffffff;
            color: #0f172a;
            border-color: #cbd5e1;
        }
        
        body[data-theme="light"] button.primary {
            background: #2563eb;
            color: white;
        }
        
        body[data-theme="light"] .info-badge {
            background: #eef2f8;
        }

        @media (max-width: 640px) {
            .output-size-grid {
                grid-template-columns: 1fr;
            }

            .custom-ratio-inputs,
            .size-shortcuts {
                flex-direction: column;
                align-items: stretch;
            }
        }
