/* ============================================
   Icon Maker - Modern Styling with Dark Mode
   ============================================ */

/* CSS Variables - Light Mode (Default) */
:root {
    --transition-speed: 0.25s;
    
    /* Primary Colors - Green Theme */
    --primary: #339966;
    --primary-light: rgba(51, 153, 102, 0.12);
    --primary-dark: #2d8557;
    --accent: #4ade80;
    
    /* Status Colors */
    --success: #339966;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #e64e4e;
    --danger-light: #fee2e2;
    --info: #3399cc;
    --info-light: #dbeafe;
    
    /* 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(51, 153, 102, 0.25);
    --shadow-primary-hover: 0 6px 20px rgba(51, 153, 102, 0.35);
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Checkerboard */
    --checker-light: #f0f0f0;
    --checker-dark: #e0e0e0;
    
    /* Input */
    --input-bg: #ffffff;
    --input-border: #e2e8f0;
}

/* Dark Mode Colors */
[data-theme="dark"] {
    --primary: #4ade80;
    --primary-light: rgba(74, 222, 128, 0.15);
    --primary-dark: #22c55e;
    --accent: #86efac;
    
    --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: #60a5fa;
    --info-light: rgba(96, 165, 250, 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(74, 222, 128, 0.2);
    --shadow-primary-hover: 0 6px 20px rgba(74, 222, 128, 0.3);
    
    --checker-light: #334155;
    --checker-dark: #475569;
    
    --input-bg: #334155;
    --input-border: #475569;
}

/* 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: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ============================================
   EDITOR LAYOUT
   ============================================ */

.editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.im-source-panel,
.im-settings-panel {
    padding: 1.5rem;
}

.im-source-panel {
    border-right: 1px solid var(--border);
}

.im-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.im-panel-header svg,
.im-panel-header i {
    color: var(--primary);
}

/* ============================================
   FILE INFO BAR
   ============================================ */

.file-info-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.file-info-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.3rem 0.65rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.file-info-item svg,
.file-info-item i {
    color: var(--primary);
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.7;
}

.file-info-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.change-file-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    padding: 0.4rem 0.85rem;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.change-file-btn svg,
.change-file-btn i {
    width: 16px;
    height: 16px;
}

/* Source Preview */
.source-preview-wrapper {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    max-height: 350px;
}

#sourceCanvas {
    max-width: 100%;
    max-height: 350px;
    display: block;
}

.source-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.85rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* ============================================
   SIZE SELECTION
   ============================================ */

.setting-group {
    margin-bottom: 1.25rem;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.6rem;
}

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

.size-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.size-option {
    cursor: pointer;
}

.size-option input { display: none; }

.size-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.size-option input:checked + .size-box {
    border-color: var(--primary);
    background: var(--primary-light);
}

.size-preview {
    background: var(--primary);
    border-radius: 3px;
    flex-shrink: 0;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.size-option input:checked + .size-box .size-preview {
    opacity: 1;
}

.size-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.size-use {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}

.size-quick-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.quick-btn {
    padding: 0.3rem 0.6rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

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

/* ============================================
   FORMAT OPTIONS
   ============================================ */

.format-options {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.4rem;
}

.format-option {
    cursor: pointer;
}

.format-option input { display: none; }

.format-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.65rem 0.4rem;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    text-align: center;
}

.format-option input:checked + .format-box {
    border-color: var(--primary);
    background: var(--primary-light);
}

.format-box svg,
.format-box i {
    color: var(--text-muted);
    transition: color 0.2s;
}

.format-option input:checked + .format-box svg,
.format-option input:checked + .format-box i {
    color: var(--primary);
}

.format-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.format-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ============================================
   BACKGROUND OPTIONS
   ============================================ */

.bg-options {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.bg-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}

.bg-option input[type="radio"] { display: none; }

.bg-box {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    transition: all 0.2s;
    overflow: hidden;
    position: relative;
}

.bg-option input[type="radio"]:checked + .bg-box,
.bg-option input[type="radio"]:checked + input[type="color"] {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.transparent-bg {
    background: repeating-conic-gradient(var(--checker-dark) 0% 25%, var(--checker-light) 0% 50%) 50% / 12px 12px;
}

.bg-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

.color-input {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
    transition: border-color 0.2s;
}

.color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.color-input::-webkit-color-swatch { border: none; border-radius: 3px; }

/* ============================================
   GENERATE BUTTON
   ============================================ */

.generate-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.85rem 1.5rem;
    background: var(--primary) !important;
    color: #fff !important;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-primary);
    margin-top: 0.5rem;
    text-decoration: none !important;
}

.generate-btn:hover {
    background: var(--primary-dark) !important;
    color: #fff !important;
    text-decoration: none !important;
    box-shadow: var(--shadow-primary-hover);
    transform: translateY(-1px);
}

.generate-btn:active {
    transform: translateY(0);
}

.generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   PROCESSING SECTION - stage-dot style (matches gif-maker)
   ============================================ */

.processing-section {
    padding: 3rem 2rem;
    text-align: center;
}

.im-processing-content {
    max-width: 400px;
    margin: 0 auto;
}

/* Stage dots row */
.im-progress-stages {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 1.75rem;
}

.im-stage-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-muted);
    transition: color 0.3s;
}

.im-stage-dot svg,
.im-stage-dot i {
    width: 20px;
    height: 20px;
    padding: 7px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.im-stage-dot span {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.im-stage-dot.active svg,
.im-stage-dot.active i {
    background: var(--primary);
    color: white;
}

.im-stage-dot.active {
    color: var(--primary);
}

.im-stage-dot.done svg,
.im-stage-dot.done i {
    background: var(--success);
    color: white;
}

.im-stage-dot.done {
    color: var(--success);
}

.im-stage-connector {
    width: 28px;
    height: 2px;
    background: var(--border);
    margin: 0 0.25rem 1rem;
    flex-shrink: 0;
}

/* Progress bar */
.im-progress-bar-container {
    width: 100%;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.im-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 0.3s ease;
}

.im-processing-status {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    margin: 0 0 0.25rem;
}

.im-progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   RESULTS SECTION
   ============================================ */

.im-results-section {
    padding: 2rem;
    text-align: center;
}

.im-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.im-results-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.im-results-title-row > i[data-lucide="check-circle"] {
    width: 22px !important;
    height: 22px !important;
    color: var(--success) !important;
    flex-shrink: 0;
}

.im-results-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

/* Download bar - pinned at bottom of results box */
.im-results-download-bar {
    display: flex;
    justify-content: center;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.im-results-actions {
    display: flex;
    gap: 0.875rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.im-results-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none !important;
}

.im-results-btn.primary {
    background: var(--primary) !important;
    color: #fff !important;
    box-shadow: var(--shadow-primary);
}

.im-results-btn.primary:hover {
    background: var(--primary-dark) !important;
    color: #fff !important;
    text-decoration: none !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-primary-hover);
}

.im-results-btn.secondary {
    background: var(--bg-elevated) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border);
    text-decoration: none !important;
    box-shadow: none;
    padding: 0.75rem 1.375rem;
    font-size: 0.9rem;
}

.im-results-btn.secondary:hover {
    background: var(--bg-secondary) !important;
    color: var(--text) !important;
    text-decoration: none !important;
}

/* Context Previews */
.preview-context-section {
    margin-bottom: 1.5rem;
}

.context-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.context-label svg,
.context-label i {
    color: var(--primary);
}

.context-previews {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

.context-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    border: 1px solid var(--border);
}

.context-card-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

/* Browser Tab Mock */
.browser-tab-preview {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.5rem;
}

.mock-tab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: var(--text);
}

.mock-tab img {
    border-radius: 2px;
    flex-shrink: 0;
}

.mock-tab-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Bookmark Bar Mock */
.bookmark-preview {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.5rem;
    display: flex;
    gap: 0.75rem;
}

.mock-bookmark {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    color: var(--text);
}

.mock-bookmark.faded {
    opacity: 0.3;
}

.mock-generic-icon {
    width: 16px;
    height: 16px;
    background: var(--border);
    border-radius: 2px;
}

/* Desktop Icon Mock */
.desktop-preview {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    justify-content: center;
}

[data-theme="dark"] .desktop-preview {
    background: linear-gradient(135deg, #1a1a3e 0%, #2d1b4e 100%);
}

.mock-desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.mock-desktop-icon img {
    border-radius: 4px;
    background: var(--bg-elevated);
    padding: 2px;
}

.mock-desktop-icon span {
    font-size: 0.65rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Size Results Grid */
/* Size results grid - flex-wrap centred like image-to-ico icon previews */
.size-results-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.875rem;
    justify-content: center;
    margin-bottom: 0;
}

/* ICO card always spans full width */
.size-results-grid .ico-result-card {
    flex: 0 0 100%;
    width: 100%;
}

.size-result-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    padding: 0.75rem 0.75rem 0.6rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    min-width: 108px;
    width: auto;
}

.size-result-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.size-result-preview {
    background: repeating-conic-gradient(var(--checker-dark) 0% 25%, var(--checker-light) 0% 50%) 50% / 10px 10px;
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    align-self: center;
}

.size-result-preview img {
    max-width: 80px;
    max-height: 80px;
    image-rendering: pixelated;
    display: block;
    border-radius: var(--radius-sm);
}

/* Footer row: label + download side by side */
.size-result-footer {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.4rem;
    margin-top: 0.1rem;
    width: 100%;
    overflow: hidden;
}

.size-result-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.size-result-meta {
    display: none; /* hidden - label carries the size info */
}

.size-result-download {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.25rem 0.5rem;
    background: var(--primary) !important;
    color: #fff !important;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.65rem !important;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    transition: background 0.2s;
    flex-shrink: 0;
    transform: none !important;
    box-shadow: none !important;
    line-height: 1;
}

.size-result-download:hover {
    background: var(--primary-dark) !important;
    color: #fff !important;
    text-decoration: none !important;
    transform: none !important;
}

.size-result-download svg,
.size-result-download i {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

/* ICO Result */
.ico-result-card {
    width: 100%;
    background: var(--primary-light);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    text-align: left;
}

.ico-result-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ico-result-icon {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.ico-result-icon svg,
.ico-result-icon i {
    width: 22px;
    height: 22px;
}

.ico-result-text h4 {
    margin: 0 0 0.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.ico-result-text p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.ico-download-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    background: var(--primary) !important;
    color: #fff !important;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.ico-download-btn:hover {
    background: var(--primary-dark) !important;
    color: #fff !important;
    text-decoration: none !important;
    transform: translateY(-1px);
}

/* Error Message */
.im-error-message {
    text-align: center;
    padding: 2rem;
    color: var(--danger);
}

.im-error-message p {
    margin: 0.5rem 0;
}

.im-error-contact {
    font-size: 0.85rem;
    color: var(--text-muted) !important;
}

.im-error-contact a {
    color: var(--primary);
    text-decoration: underline;
}

/* ============================================
   INFO SECTIONS (description content)
   ============================================ */

.im-info-sections {
    margin-top: 2.5rem;
}

.im-info-card h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 1rem;
}

.im-info-card h2 svg,
.im-info-card h2 i {
    color: var(--primary);
    flex-shrink: 0;
}

.im-steps-list {
    padding-left: 1.25rem;
    margin: 0;
}

.im-steps-list li {
    margin-bottom: 0.65rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

.im-steps-list li a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.im-steps-list li a:hover {
    text-decoration: underline;
}

/* Mode Explanations */
.mode-explanations {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mode-explain {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}

.mode-tag {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.size-tag {
    background: var(--primary-light);
    color: var(--primary);
}

.tip-tag {
    background: var(--success-light);
    color: var(--success);
}

.mode-explain p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.mode-explain p a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.mode-explain p a:hover {
    text-decoration: underline;
}

/* ============================================
   RELATED TOOLS  (pill-box style, matches image-to-ico)
   ============================================ */

.im-related-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.875rem;
    margin-top: 1.75rem;
    padding: 1.125rem 1.5rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.im-related-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--text);
    font-size: 0.875rem;
    white-space: nowrap;
}

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

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

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

.im-related-link:hover {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary);
    text-decoration: none !important;
}

.im-related-link svg,
.im-related-link i {
    width: 13px;
    height: 13px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .tool-container {
        padding: 1rem;
    }
    
    .editor-layout {
        grid-template-columns: 1fr;
    }
    
    .im-source-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .file-info-bar {
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }
    
    .file-info-item span {
        max-width: 120px;
    }
    
    .change-file-btn span {
        display: none;
    }
    
    .context-previews {
        grid-template-columns: 1fr;
    }
    
    .size-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .ico-result-card {
        flex-direction: column;
        text-align: center;
    }
    
    .ico-result-info {
        flex-direction: column;
    }
    
    .im-results-header {
        flex-direction: column;
        text-align: center;
    }
    
    .format-options {
        grid-template-columns: 1fr;
    }
}

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

/* ============================================
   SHAPE MASK SELECTOR
   ============================================ */

.im-shape-options {
    display: flex;
    gap: 0.5rem;
}

.im-shape-option {
    cursor: pointer;
    flex: 1;
}

.im-shape-option input[type="radio"] {
    display: none;
    width: 0;
    height: 0;
    position: absolute;
}

.im-shape-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.4rem;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    text-align: center;
    cursor: pointer;
}

.im-shape-option input[type="radio"]:checked + .im-shape-box {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* Shape preview blocks - distinct shapes */
.im-shape-preview {
    display: block;
    width: 28px;
    height: 28px;
    background: var(--primary);
    opacity: 0.4;
    transition: opacity 0.2s, border-radius 0.2s;
    flex-shrink: 0;
    /* default: square */
    border-radius: 3px;
}

.im-shape-option input[type="radio"]:checked + .im-shape-box .im-shape-preview {
    opacity: 1;
}

/* Explicit shape styles - use !important to beat any inherited rules */
span.im-shape-preview.square  { border-radius: 3px !important; }
span.im-shape-preview.rounded { border-radius: 8px !important; }
span.im-shape-preview.circle  { border-radius: 50% !important; }

.im-shape-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

/* Tool description max-width */
.tool-description {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Results preview spacing */
.preview-context-section {
    margin-bottom: 1.75rem;
}

/* ============================================
   GLOBAL OVERRIDES
   custom_styles.css sets overflow:hidden on .tool-main which clips
   the crop overlay, context previews, and dropdowns. Override it.
   ============================================ */
.tool-main {
    overflow: visible !important;
}

/* im-info-card: white card with shadow (restore white bg) */
.im-info-card {
    background: var(--card-bg, var(--bg-elevated, #fff)) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-sm, 0 1px 4px rgba(0,0,0,0.08)) !important;
    border-radius: var(--radius-lg) !important;
    padding: 1.75rem 2rem !important;
    margin-bottom: 1.75rem;
}
