:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --success: #059669;
    --text: #1F2937;
    --text-light: #6B7280;
    --text-lighter: #9CA3AF;
    --bg: #F9FAFB;
    --white: #FFFFFF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --max-width: 960px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

.header { background: var(--white); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.header-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    height: 60px;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    direction: ltr;
}
.logo { font-size: 1.25rem; font-weight: 700; color: var(--primary); text-decoration: none; justify-self: start; }
.logo span { color: var(--text-light); font-weight: 400; }
.nav { display: flex; align-items: center; justify-content: center; }
.nav-links { display: flex; list-style: none; gap: 4px; }
.nav-links a { display: block; padding: 11px 16px; color: var(--text-light); text-decoration: none; font-size: 0.9rem; font-weight: 500; border-radius: var(--radius); transition: all 0.15s; }
.nav-links a:hover { color: var(--primary); background: var(--primary-light); }
.nav-links a.active { color: var(--primary); background: var(--primary-light); }

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-self: end;
}

.lang-switcher {
    padding: 9px 28px 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    font-size: 0.85rem;
    min-height: 38px;
    min-width: 80px;
    max-width: 140px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

.lang-switcher:hover { border-color: var(--primary); }
.lang-switcher:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

.main { min-height: calc(100vh - 60px); }

.hero { text-align: center; padding: 48px 0 32px; }
.hero h1 { font-size: 2rem; font-weight: 800; color: var(--text); margin-bottom: 12px; }
.hero-subtitle { font-size: 1.1rem; color: var(--text-light); margin-bottom: 20px; }
.trust-badges { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; background: var(--white); border: 1px solid var(--border); border-radius: 100px; font-size: 0.875rem; font-weight: 500; color: var(--text); }

.tool-section { padding: 0 0 48px; }
.tool-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 32px; box-shadow: var(--shadow); }

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 52px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.01);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1), var(--shadow-lg);
}
.upload-area.drag-over .upload-icon-svg { transform: translateY(-4px) scale(1.1); color: var(--primary); }
.upload-icon-svg { color: var(--text-lighter); margin-bottom: 12px; transition: all 0.25s ease; }
.upload-text { font-size: 1rem; color: var(--text-light); margin-bottom: 4px; }
.upload-label { color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: underline; }
.upload-hint { font-size: 0.875rem; color: var(--text-lighter); }
.upload-hint-paste { font-size: 0.8rem; color: var(--text-lighter); margin-top: 8px; opacity: 0.7; }

.editor-area { display: flex; flex-direction: column; gap: 20px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.editor-top { display: flex; flex-direction: column; gap: 16px; }

.image-list-wrapper { margin-bottom: 0; }
.image-list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.image-list-header h3 { font-size: 1rem; font-weight: 600; }
.image-list-actions { display: flex; gap: 8px; }

.image-list { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px; background: var(--bg); border-radius: var(--radius); min-height: 80px; }

.image-item {
    position: relative;
    width: 112px;
    height: 112px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
    cursor: grab;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.image-item:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.image-item.sortable-ghost { opacity: 0.35; }
.image-item.sortable-chosen { border-color: var(--primary); transform: scale(1.05); box-shadow: var(--shadow-lg); z-index: 10; }
.image-item img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

.remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    background: rgba(0,0,0,0.55);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    transition: all 0.15s;
    z-index: 5;
}
.remove-btn:hover { background: var(--danger); opacity: 1; transform: scale(1.1); }

.drag-grip {
    position: absolute;
    bottom: 4px;
    left: 4px;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    background: rgba(0,0,0,0.45);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0.6;
    transition: opacity 0.15s;
    cursor: grab;
    z-index: 5;
}
.image-item:hover .drag-grip { opacity: 1; }

.image-badge { position: absolute; top: 4px; left: 4px; padding: 2px 7px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; color: white; pointer-events: none; z-index: 5; }
.badge-before { background: var(--primary); }
.badge-after { background: var(--success); }
.badge-unused { background: rgba(0,0,0,0.4); }

.drop-zone-mini {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    margin-top: 8px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-lighter);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.drop-zone-mini:hover, .drop-zone-mini.drag-over { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

.layout-section { display: flex; flex-direction: column; gap: 8px; }
.layout-selector { display: flex; gap: 8px; }
.layout-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    color: var(--text-light);
}
.layout-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.layout-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.layout-btn svg { display: block; }
.layout-btn span { font-size: 0.85rem; font-weight: 600; }

.layout-options { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.layout-options .option-group { margin-bottom: 0; }

.editor-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.settings-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.settings-title { font-size: 0.85rem; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.05em; }
.settings-row { display: flex; flex-direction: column; gap: 16px; }
.settings-row .option-group { margin-bottom: 0; }

.option-group { margin-bottom: 16px; }
.option-label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }

.radio-group { display: flex; gap: 8px; }
.radio-card { flex: 1; cursor: pointer; min-width: 0; }
.radio-card input { display: none; }
.radio-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    min-height: 40px;
    transition: all 0.15s;
    text-align: center;
    white-space: nowrap;
}
.radio-card input:checked + .radio-visual { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.radio-card input:focus + .radio-visual { outline: 2px solid var(--primary); outline-offset: 1px; }

.slider-group { display: flex; align-items: center; gap: 10px; }
.slider-group input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}
.slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s;
}
.slider-group input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: var(--shadow-sm);
}
.slider-value { font-size: 0.85rem; font-weight: 600; color: var(--primary); min-width: 40px; text-align: end; }

.color-group { display: flex; align-items: center; gap: 8px; }
.color-group input[type="color"] {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 2px;
}
.color-value { font-size: 0.85rem; font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace; color: var(--text-light); }

.select {
    width: 100%;
    padding: 9px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--white);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}
.select:focus { border-color: var(--primary); }

.dimension-inputs { display: flex; align-items: flex-end; gap: 8px; }
.dimension-field { display: flex; align-items: center; gap: 4px; flex: 1; }
.dimension-field label { font-size: 0.8rem; font-weight: 500; color: var(--text-light); min-width: 16px; }
.input-field {
    width: 100%;
    padding: 9px 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}
.input-field:focus { border-color: var(--primary); }
.input-field::placeholder { color: var(--text-lighter); }
.dimension-field span { font-size: 0.8rem; color: var(--text-lighter); }
.dim-separator { font-size: 0.9rem; color: var(--text-lighter); font-weight: 500; padding-bottom: 4px; }

.preview-section { display: flex; flex-direction: column; gap: 10px; }
.preview-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.preview-info { font-size: 0.88rem; color: var(--text-light); font-weight: 500; }
.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.preview-area {
    background-image:
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}
.preview-area img {
    max-width: 100%;
    max-height: 65vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    animation: previewIn 0.3s ease;
}
@keyframes previewIn { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }
.preview-placeholder {
    font-size: 0.92rem;
    color: var(--text-lighter);
    text-align: center;
    background: var(--white);
    padding: 12px 20px;
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

.preview-footer { text-align: center; padding-top: 6px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    font-family: inherit;
    min-height: 38px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: #D1D5DB; color: #9CA3AF; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-outline { background: transparent; color: var(--text-light); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: #FEF2F2; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; min-height: 40px; }

.how-it-works { padding: 64px 0; }
.how-it-works h2 { text-align: center; font-size: 1.5rem; font-weight: 700; margin-bottom: 40px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.step { text-align: center; }
.step-number { width: 48px; height: 48px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; font-weight: 700; margin: 0 auto 16px; }
.step h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.step p { font-size: 0.9rem; color: var(--text-light); }

.features { padding: 64px 0; background: var(--white); }
.features h2 { text-align: center; font-size: 1.5rem; font-weight: 700; margin-bottom: 40px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.feature-card { padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.feature-icon-svg { color: var(--primary); margin-bottom: 12px; }
.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.feature-card p { font-size: 0.9rem; color: var(--text-light); }

.use-cases { padding: 64px 0; }
.use-cases h2 { text-align: center; font-size: 1.5rem; font-weight: 700; margin-bottom: 40px; }
.use-case-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.use-case-card { padding: 20px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); }
.use-case-icon { color: var(--primary); margin-bottom: 8px; }
.use-case-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.use-case-card p { font-size: 0.875rem; color: var(--text-light); }

.faq { padding: 64px 0; background: var(--white); }
.faq h2 { text-align: center; font-size: 1.5rem; font-weight: 700; margin-bottom: 40px; }
.faq-list { max-width: 680px; margin: 0 auto; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item summary {
    padding: 17px 0;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-size: 1.2rem; color: var(--text-lighter); flex-shrink: 0; margin-inline-start: 12px; }
.faq-item[open] summary::after { content: '−'; }
.faq-item p { padding: 0 0 17px; font-size: 0.9rem; color: var(--text-light); line-height: 1.7; }

.footer { background: var(--text); color: #D1D5DB; padding: 48px 0 24px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; margin-bottom: 32px; }
.footer-brand .logo { color: white; display: inline-block; margin-bottom: 8px; }
.footer-brand p { font-size: 0.85rem; color: #9CA3AF; }
.footer-links h4 { font-size: 0.85rem; font-weight: 600; color: white; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.footer-links ul { list-style: none; }
.footer-links li { margin-bottom: 8px; }
.footer-links a { color: #9CA3AF; text-decoration: none; font-size: 0.875rem; transition: color 0.15s; }
.footer-links a:hover { color: white; }
.footer-bottom { border-top: 1px solid #374151; padding-top: 20px; text-align: center; font-size: 0.85rem; color: #6B7280; }

.compress-list { display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--bg); border-radius: var(--radius); min-height: 60px; }
.compress-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow 0.15s;
    position: relative;
}
.compress-item:hover { box-shadow: var(--shadow-sm); }
.compress-thumb { width: 52px; height: 52px; border-radius: 6px; overflow: hidden; flex-shrink: 0; }
.compress-thumb img { width: 100%; height: 100%; object-fit: cover; }
.compress-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.compress-name { font-size: 0.86rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compress-size { font-size: 0.8rem; color: var(--text-lighter); }
.compress-results { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.compress-result-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius);
    flex-wrap: wrap;
}
.result-name { flex: 1; min-width: 120px; font-size: 0.86rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-before { font-size: 0.86rem; color: var(--text-light); }
.result-arrow { color: var(--text-lighter); }
.result-after { font-size: 0.86rem; font-weight: 600; color: var(--text); }
.result-saving { font-size: 0.86rem; font-weight: 700; }
.saving-positive { color: #059669; }
.saving-negative { color: var(--danger); }
.result-summary { font-size: 0.92rem; font-weight: 600; color: var(--text); margin-bottom: 16px; text-align: center; }

.resize-preview { margin-bottom: 24px; text-align: center; }
.resize-preview h3 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.preview-container {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 8px;
    overflow: auto;
}
.preview-container img { max-width: 100%; max-height: 65vh; width: auto; height: auto; object-fit: contain; border-radius: 4px; }

.lock-btn {
    width: 42px;
    height: 42px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.lock-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.lock-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

.legal-page { padding: 48px 0 64px; }
.legal-page h1 { font-size: 2rem; font-weight: 800; margin-bottom: 8px; }
.legal-page h2 { font-size: 1.15rem; font-weight: 700; margin-top: 32px; margin-bottom: 12px; color: var(--text); }
.legal-page p { font-size: 0.95rem; color: var(--text-light); line-height: 1.7; margin-bottom: 12px; }
.legal-page ul { margin: 8px 0 16px 24px; font-size: 0.95rem; color: var(--text-light); line-height: 1.8; }
.legal-page li { margin-bottom: 4px; }
.legal-page a { color: var(--primary); text-decoration: none; }
.legal-page a:hover { text-decoration: underline; }
.legal-updated { font-size: 0.85rem; color: var(--text-lighter); margin-bottom: 24px; }

.size-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.size-btn {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    text-align: center;
    transition: all 0.15s;
    font-family: inherit;
    min-height: 44px;
}
.size-btn small { display: block; font-size: 0.7rem; color: var(--text-lighter); font-weight: 400; margin-top: 2px; }
.size-btn:hover, .size-btn.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

.position-grid { display: none; }

.crop-editor {
    position: relative;
    display: block;
    max-width: 100%;
    margin: 0 auto;
    background:
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border-radius: var(--radius);
    overflow: hidden;
    touch-action: none;
    user-select: none;
}
.crop-editor img {
    display: block;
    max-width: 100%;
    height: auto;
}
.crop-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}
.crop-info-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 12px;
    margin-top: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}
.crop-info-bar strong { color: var(--primary); }

.crop-hint {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.4s ease;
    z-index: 5;
    white-space: nowrap;
}
.crop-hint.hidden { opacity: 0; }

.preset-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-btn {
    padding: 8px 14px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 90px;
}
.preset-btn .preset-name { font-weight: 500; white-space: nowrap; }
.preset-btn .preset-dim { font-size: 0.72rem; color: var(--text-lighter); font-weight: 400; }
.preset-btn:hover { border-color: var(--primary); }
.preset-btn:hover .preset-name { color: var(--primary); }
.preset-btn.selected {
    background: var(--primary-light);
    border-color: var(--primary);
}
.preset-btn.selected .preset-name { color: var(--primary); font-weight: 600; }
.preset-btn.selected .preset-dim { color: var(--primary); opacity: 0.8; }

.template-bar {
    padding: 14px 18px;
    background: var(--bg);
    border-top: 1px solid var(--border);
}
.template-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.template-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-light);
    transition: all 0.15s;
}
.template-btn:hover { border-color: var(--primary); }
.template-btn:hover .template-name { color: var(--primary); }
.template-btn.selected {
    background: var(--primary-light);
    border-color: var(--primary);
}
.template-btn.selected .template-name { color: var(--primary); font-weight: 600; }
.template-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.6;
}
.template-btn.selected .template-icon { opacity: 1; color: var(--primary); }

.options-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    animation: fadeIn 0.3s ease;
}

.result-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    animation: fadeIn 0.3s ease;
}
.result-area h3 { font-size: 1.08rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }

.result-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    overflow: auto;
}
.result-preview img { max-width: 100%; max-height: 55vh; width: auto; height: auto; object-fit: contain; border-radius: 4px; }

.result-info { font-size: 0.9rem; color: var(--text-light); font-weight: 500; text-align: center; }

@media (min-width: 769px) {
    .editor-main {
        flex-direction: row;
        align-items: flex-start;
    }
    .settings-panel { flex: 0 0 360px; min-width: 320px; }
    .preview-section { flex: 1; min-width: 0; }
}

@media (max-width: 768px) {
    .hero h1 { font-size: 1.5rem; }
    .hero { padding: 32px 0 24px; }
    .hero-subtitle { font-size: 0.95rem; }
    .tool-card { padding: 16px; }
    .steps, .feature-grid, .use-case-grid { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .nav-links { gap: 0; }
    .nav-links a { padding: 12px 14px; font-size: 0.85rem; }
    .upload-area { padding: 36px 16px; }
    .image-item { width: 90px; height: 90px; }
    .image-item .remove-btn { width: 36px; height: 36px; font-size: 14px; }
    .layout-selector { flex-wrap: wrap; }
    .layout-btn { min-width: calc(50% - 6px); padding: 10px 6px; }
    .layout-btn span { font-size: 0.78rem; }
    .layout-btn svg { width: 28px; height: 28px; }
    .settings-row { flex-direction: column; gap: 16px; }
    .settings-row .option-group { min-width: 100%; }
    .layout-options { flex-direction: column; }
    .preview-area { padding: 10px; min-height: 120px; }
    .preview-area img { max-height: 50vh; }
    .preview-actions { flex-wrap: wrap; }
    .editor-main { flex-direction: column !important; }
    .settings-panel { flex: none !important; width: auto !important; min-width: auto !important; }
    .compress-thumb { width: 46px; height: 46px; }
    .btn { min-height: 44px; }
    .btn-sm { min-height: 44px; padding: 9px 14px; }
    .size-btn { min-height: 44px; }
    .pos-btn { width: 54px; height: 44px; }
    .slider-group input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; }
    .lock-btn { width: 44px; height: 44px; }
    .tool-section { padding-bottom: 70px; }
    .footer { padding-bottom: 70px; }
    .ad-top { min-height: 100px; }
    .tool-grid { grid-template-columns: repeat(2, 1fr); }
    .options-panel { padding: 14px; gap: 14px; }
    .result-area { padding: 16px; gap: 12px; }
    .compare-modal-content { width: 96vw; max-width: none; border-radius: var(--radius-lg); }
    .compare-modal-header { padding: 12px 16px; }
    .compare-side { max-height: 55vh; }
    .compare-slider-handle { width: 48px; height: 48px; font-size: 1rem; }
    .compare-label { font-size: 0.72rem; padding: 4px 10px; }
    .compare-info-bar { font-size: 0.78rem; gap: 12px; flex-wrap: wrap; }
    .preset-btn { font-size: 0.8rem; padding: 8px 10px; min-width: 0; flex: 1 1 calc(50% - 4px); }

    /* Template bar responsive */
    .template-bar { padding: 10px 14px; }
    .template-buttons { gap: 6px; }
    .template-btn { padding: 6px 10px; font-size: 0.78rem; }
    .template-icon { width: 18px; height: 18px; }
    .template-name { font-size: 0.75rem; }

    /* Uniform radio group - allow wrap for 5 options */
    .radio-group { flex-wrap: wrap; gap: 6px; }
    .radio-visual { padding: 10px 8px; font-size: 0.8rem; white-space: normal; min-height: 42px; }

    /* Slider larger touch targets */
    .slider-group input[type="range"] { height: 8px; }
}

@media (max-width: 480px) {
    .radio-group { flex-wrap: wrap; }
    .radio-visual { padding: 10px 6px; font-size: 0.78rem; min-height: 44px; }
    .dimension-inputs { flex-wrap: wrap; }
    .dimension-field { min-width: 80px; }
    .template-grid { grid-template-columns: repeat(3, 1fr); }
    .image-item { width: 76px; height: 76px; }
    .remove-btn { width: 28px; height: 28px; font-size: 12px; top: 2px; right: 2px; }
    .drag-grip { width: 22px; height: 22px; bottom: 2px; left: 2px; }
    .preview-header { flex-direction: column; align-items: stretch; }
    .preview-actions { justify-content: stretch; }
    .preview-actions .btn { flex: 1; }
    .tool-grid { grid-template-columns: 1fr; }

    /* Layout buttons - 4 items in 2x2 grid */
    .layout-btn { min-width: calc(50% - 5px); padding: 8px 4px; }
    .layout-btn span { font-size: 0.72rem; }
    .layout-btn svg { width: 24px; height: 24px; }

    /* Template buttons - smaller on tiny screens */
    .template-bar { padding: 8px 10px; }
    .template-buttons { gap: 4px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .template-btn { padding: 5px 8px; font-size: 0.72rem; gap: 4px; flex-shrink: 0; }
    .template-icon { width: 16px; height: 16px; display: none; }
    .template-name { font-size: 0.7rem; white-space: nowrap; }

    /* Preset buttons - compact */
    .preset-btn { padding: 6px 8px; font-size: 0.75rem; gap: 1px; }
    .preset-dim { font-size: 0.68rem; }

    /* Footer single column */
    .footer-grid { grid-template-columns: 1fr; gap: 20px; }

    /* Settings more compact */
    .option-label { font-size: 0.8rem; margin-bottom: 4px; }
    .option-group { margin-bottom: 12px; }
    .settings-panel { padding: 12px; gap: 12px; }
    .color-group input[type="color"] { width: 36px; height: 36px; }

    /* Upload area */
    .upload-area { padding: 28px 12px; }
    .upload-text { font-size: 0.9rem; }

    /* Hero even smaller */
    .hero h1 { font-size: 1.3rem; }
    .hero-subtitle { font-size: 0.85rem; }
}

/* Medium breakpoint: large phones / small tablets in portrait (481px - 768px) */
@media (min-width: 481px) and (max-width: 600px) {
    .layout-btn { min-width: calc(50% - 5px); padding: 9px 5px; }
    .layout-btn span { font-size: 0.75rem; }
    .layout-btn svg { width: 26px; height: 26px; }
    .template-btn { font-size: 0.76rem; padding: 6px 10px; }
    .template-icon { width: 17px; height: 17px; }
    .preset-btn { flex: 1 1 calc(45% - 4px); }
    .radio-visual { padding: 10px 8px; font-size: 0.8rem; white-space: normal; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
}

/* Landscape phone mode */
@media (max-height: 500px) and (orientation: landscape) {
    .header-inner { height: 50px; }
    .hero { padding: 16px 0 12px; }
    .hero h1 { font-size: 1.2rem; margin-bottom: 6px; }
    .hero-subtitle { font-size: 0.82rem; margin-bottom: 10px; display: none; }
    .trust-badges { gap: 6px; }
    .badge { padding: 4px 10px; font-size: 0.75rem; }
    .tool-card { padding: 12px; }
    .upload-area { padding: 20px 16px; }
    .editor-main { gap: 16px; }
    .settings-panel { padding: 12px; gap: 10px; }
    .preview-area { min-height: 100px; max-height: 40vh; }
    .preview-area img { max-height: 38vh; }
    .how-it-works, .features, .use-cases, .faq, .related-tools { padding: 32px 0; }
    .steps, .feature-grid, .use-case-grid { gap: 16px; }
    .footer { padding: 24px 0 16px; }
    .safe-area-bottom { padding-bottom: env(safe-area-inset-bottom, 4px); }
}

.related-tools {
    padding: 48px 0;
    background: var(--white);
}

.related-tools h2 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 32px;
    color: var(--text);
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.tool-link {
    display: block;
    padding: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s ease;
}

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

.tool-link h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--primary);
}

.tool-link p {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.4;
}

.upload-icon {
    margin-bottom: 12px;
    color: var(--text-lighter);
}

.feature-icon {
    margin-bottom: 12px;
    color: var(--primary);
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.05rem;
    font-weight: 600;
    width: 100%;
    min-height: 50px;
}

.option-hint {
    font-size: 0.82rem;
    color: var(--text-lighter);
    margin-top: 6px;
}

.ad-container {
    text-align: center;
    margin: 24px auto;
    max-width: var(--max-width);
    padding: 0 20px;
}

.ad-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-lighter);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.ad-top {
    min-height: 90px;
    background: var(--border-light);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
}

.ad-infeed {
    min-height: 120px;
    padding: 16px 20px;
}

.ad-anchor {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 6px 0;
    display: none;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

@media (max-width: 768px) {
    .ad-anchor { display: block; }
}

@media (min-width: 769px) {
    .ad-anchor { display: none !important; }
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

input[type="range"]:focus-visible {
    outline: none;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--primary-light), var(--shadow-sm);
}

html { scroll-behavior: smooth; }

.toast-container { position: fixed; z-index: 10001; pointer-events: none; display: flex; flex-direction: column; gap: 8px; max-width: 380px; width: calc(100% - 24px); }
.toast-container.top-right { top: 16px; right: 16px; }
.toast-container.top-center { top: 16px; left: 50%; transform: translateX(-50%); align-items: center; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 8px; background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.15); pointer-events: auto; animation: toastIn 0.3s ease forwards; min-height: 44px; }
.toast.removing { animation: toastOut 0.25s ease forwards; }
.toast-error { border-inline-start: 4px solid #EF4444; }
.toast-success { border-inline-start: 4px solid #10B981; }
.toast-info { border-inline-start: 4px solid var(--primary, #4F46E5); }
.toast-icon { flex-shrink: 0; width: 20px; height: 20px; }
.toast-message { flex: 1; font-size: 14px; line-height: 1.4; color: var(--text, #1F2937); }
.toast-close { flex-shrink: 0; background: none; border: none; cursor: pointer; padding: 2px; opacity: 0.5; transition: opacity 0.15s; color: inherit; font-size: 18px; line-height: 1; }
.toast-close:hover { opacity: 1; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
@media (max-width: 768px) {
    .toast-container { position: fixed; top: auto; bottom: 80px; left: 12px; right: 12px; transform: none; }
    .toast-container.top-center { left: 12px; right: 12px; transform: none; }
}

.hamburger { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 40px; height: 40px; background: none; border: none; cursor: pointer; padding: 6px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: all 0.25s ease; }
.hamburger span:nth-child(1) { transform-origin: center; }
.hamburger span:nth-child(3) { transform-origin: center; }
.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

@media (max-width: 768px) {
    .hamburger { display: flex; }
    .nav {
        position: fixed; top: 60px; left: 0; right: 0; bottom: 0;
        background: rgba(255,255,255,0.97); backdrop-filter: blur(8px);
        flex-direction: column; gap: 0; padding: 16px;
        transform: translateX(100%); transition: transform 0.3s ease;
        z-index: 99; overflow-y: auto;
    }
    .nav.open { transform: translateX(0); }
    .nav .nav-links { flex-direction: column; gap: 0; width: 100%; }
    .nav .nav-links a {
        display: block; padding: 14px 16px; font-size: 1rem;
        border-bottom: 1px solid var(--border);
        min-height: 48px; text-align: start;
    }
    .header-controls .lang-switcher {
        min-width: 0;
        max-width: 100px;
        font-size: 0.8rem;
        padding: 6px 20px 6px 8px;
    }
    [dir="rtl"] .nav {
        transform: translateX(-100%);
    }
    [dir="rtl"] .nav.open {
        transform: translateX(0);
    }
}

.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
    content: '';
    position: absolute; top: 50%; left: 50%;
    width: 18px; height: 18px; margin: -9px 0 0 -9px;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-primary.loading::after { border-color: rgba(255,255,255,0.3); border-top-color: #fff; }
.btn-outline.loading::after { border-color: var(--primary); border-top-color: transparent; }
.btn-danger.loading::after { border-color: var(--danger); border-top-color: transparent; }

@media (max-width: 375px) {
    .container { padding: 12px; }
    h1 { font-size: 1.35rem; }
    .hero h1 { font-size: 1.2rem; }
    .hero p { font-size: 0.8rem; }
    .badge { font-size: 0.65rem; padding: 3px 8px; }
    .upload-area { padding: 24px 10px; }
    .settings-panel { padding: 10px; gap: 10px; }
    .feature-grid { grid-template-columns: 1fr; }
    .tool-grid { grid-template-columns: 1fr; }

    /* Layout buttons - still 2x2 but tighter */
    .layout-btn { min-width: calc(50% - 4px); padding: 7px 3px; }
    .layout-btn span { font-size: 0.68rem; }
    .layout-btn svg { width: 22px; height: 22px; }

    /* Template bar - horizontal scroll, hide icons */
    .template-bar { padding: 6px 8px; }
    .template-btn { padding: 4px 8px; font-size: 0.7rem; gap: 3px; }
    .template-icon { display: none; }
    .template-name { font-size: 0.65rem; }

    /* Radio cards even smaller */
    .radio-visual { padding: 8px 4px; font-size: 0.72rem; min-height: 40px; }
}

/* Large desktop (1200px+) */
@media (min-width: 1200px) {
    :root { --max-width: 1100px; }
    .editor-main .settings-panel { flex: 0 0 380px; }
}

/* Extra large desktop (1440px+) */
@media (min-width: 1440px) {
    :root { --max-width: 1200px; }
}

@media (max-width: 1024px) and (min-width: 769px) {
    :root { --max-width: 900px; }
    .editor-main .settings-panel { width: 340px; }
    .nav-links a { padding: 11px 12px; font-size: 0.87rem; }
    .header-inner { padding: 0 16px; }
}

.safe-area-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }
.safe-area-top { padding-top: env(safe-area-inset-top, 0px); }

@media (max-width: 768px) {
    .crop-editor { border-radius: var(--radius); }
    .crop-info-bar { font-size: 0.8rem; padding: 6px 10px; }
    .ad-anchor { padding-bottom: env(safe-area-inset-bottom, 6px); }
    .footer { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
    .tool-section { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }

    /* Safe area for editor on notch phones */
    .editor-area { padding-top: env(safe-area-inset-top, 0px); }
    .preview-footer { padding-bottom: env(safe-area-inset-bottom, 8px); }

    /* Template bar safe area */
    .template-bar { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}

@supports (-webkit-touch-callout: none) {
    .crop-canvas { touch-action: none; }
}

@media (hover: none) and (pointer: coarse) {
    .pos-btn { min-width: 48px; min-height: 48px; }
    .size-btn { min-height: 48px; padding: 10px 12px; }
    .layout-btn { min-height: 52px; padding: 12px 8px; }
    .radio-visual { min-height: 48px; padding: 14px; }
    .btn-sm { min-height: 48px; }
    .template-btn { min-height: 40px; padding: 8px 12px; }
    .preset-btn { min-height: 42px; padding: 10px 12px; }
}

::selection {
    background: rgba(79, 70, 229, 0.2);
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.auto-compress-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 6px 0;
    user-select: none;
}
.auto-compress-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}
.auto-compress-label span:hover { color: var(--text); }

.result-name-clickable {
    cursor: pointer;
    transition: color 0.15s;
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
}
.result-name-clickable:hover { color: var(--primary-hover); text-decoration: underline; }
.result-dimensions { font-size: 0.78rem; color: var(--text-lighter); white-space: nowrap; }

.saving-bar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
}
.saving-bar-track {
    width: 60px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}
.saving-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.saving-high .saving-bar-fill { background: #059669; width: 100%; }
.saving-high { color: #059669 !important; }
.saving-mid .saving-bar-fill { background: #F59E0B; width: 70%; }
.saving-mid { color: #D97706 !important; }
.saving-low .saving-bar-fill { background: #9CA3AF; width: 35%; }
.saving-low { color: #6B7280 !important; }
.saving-neg .saving-bar-fill { background: #EF4444; width: 100%; }
.saving-neg { color: #EF4444 !important; }

.zip-btn { position: relative; }
.zip-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.compare-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.compare-modal.open { display: flex; }
.compare-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
}
.compare-modal-content {
    position: relative;
    z-index: 1;
    width: 92vw;
    max-width: 900px;
    max-height: 90vh;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: compareModalIn 0.25s ease;
}
@keyframes compareModalIn { from { opacity: 0; transform: scale(0.96) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.compare-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.compare-modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text); margin: 0; }
.compare-close-btn {
    width: 36px; height: 36px;
    border: none; border-radius: 50%;
    background: var(--bg);
    color: var(--text-light);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    line-height: 1;
}
.compare-close-btn:hover { background: var(--danger); color: white; }

.compare-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    cursor: ew-resize;
    user-select: none;
    touch-action: none;
    line-height: 0;
    background:
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.compare-side {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
}
.compare-compressed {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    clip-path: inset(0 0 0 50%);
}

.compare-slider {
    position: absolute;
    top: 0; bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.compare-slider-line {
    position: absolute;
    top: 0; bottom: 0;
    width: 3px;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
}
.compare-slider-handle {
    width: 44px; height: 44px;
    background: var(--white);
    border: 3px solid rgba(0,0,0,0.15);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    color: var(--text-light);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: ew-resize;
    pointer-events: auto;
    transition: box-shadow 0.15s, transform 0.15s;
    flex-shrink: 0;
    z-index: 3;
}
.compare-slider-handle:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.3); transform: scale(1.08); }
.compare-slider-handle.dragging { box-shadow: 0 4px 12px rgba(0,0,0,0.3); transform: scale(0.95); }

.compare-label {
    position: absolute;
    bottom: 16px;
    padding: 5px 14px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-radius: 4px;
    z-index: 4;
    pointer-events: none;
    transition: opacity 0.2s;
}
.compare-label-left { left: 16px; }
.compare-label-right { right: 16px; }

.compare-info-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 10px 16px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-light);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    flex-shrink: 0;
}
.compare-info-bar strong { color: var(--primary); }

.crop-actions { display: flex; gap: 8px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.crop-action-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: var(--white); border: 1.5px solid var(--border);
    border-radius: var(--radius); cursor: pointer;
    font-size: 0.85rem; color: var(--text-light);
    transition: all 0.15s; font-family: inherit;
}
.crop-action-btn:hover { border-color: var(--primary); color: var(--primary); }
.crop-action-btn svg { flex-shrink: 0; }
@media (max-width: 768px) {
    .crop-action-btn { padding: 10px 12px; font-size: 0.82rem; }
    .crop-action-btn span { display: none; }
}

.theme-toggle {
    background: none; border: 1.5px solid var(--border);
    border-radius: var(--radius); cursor: pointer;
    padding: 6px 8px; display: flex; align-items: center; justify-content: center;
    color: var(--text-light); transition: all 0.2s;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }
[data-theme="dark"] .theme-toggle { border-color: rgba(255,255,255,0.15); }

[data-theme="dark"] {
    --bg: #0f1117;
    --bg-secondary: #1a1d27;
    --card-bg: #1e2130;
    --text: #e4e4e7;
    --text-light: #a1a1aa;
    --text-lighter: #71717a;
    --border: rgba(255,255,255,0.08);
    --border-light: rgba(255,255,255,0.04);
    --white: #1e2130;
    --shadow: 0 4px 20px rgba(0,0,0,0.4);
    --primary-light: rgba(79,70,229,0.2);
    --code-bg: #27272a;
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .header { background: rgba(15,17,23,0.95); border-bottom-color: var(--border); }
[data-theme="dark"] .tool-card { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .upload-area { background: var(--bg-secondary); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .upload-area:hover { border-color: var(--primary); }
[data-theme="dark"] .option-group { background: transparent; }
[data-theme="dark"] select, [data-theme="dark"] input[type="number"], [data-theme="dark"] input[type="text"] {
    background: var(--bg-secondary); color: var(--text); border-color: var(--border);
}
[data-theme="dark"] .footer { background: var(--bg-secondary); border-top-color: var(--border); }
[data-theme="dark"] .hero { background: linear-gradient(135deg, #1a1d27 0%, #0f1117 100%); }
[data-theme="dark"] .feature-card, [data-theme="dark"] .step, [data-theme="dark"] .faq-item, [data-theme="dark"] .tool-link, [data-theme="dark"] .related-tool-card {
    background: var(--card-bg); border-color: var(--border);
}
[data-theme="dark"] .ad-container { background: var(--bg-secondary); }
[data-theme="dark"] .crop-editor {
    background-image:
        linear-gradient(45deg, #2a2d3a 25%, transparent 25%),
        linear-gradient(-45deg, #2a2d3a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2a2d3a 75%),
        linear-gradient(-45deg, transparent 75%, #2a2d3a 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
[data-theme="dark"] .compress-item { background: var(--bg-secondary); border-color: var(--border); }
[data-theme="dark"] .compress-result-row { border-color: var(--border); background: var(--bg-secondary); }
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.8); }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
.icon-moon { display: none; }
@media (max-width: 768px) { [data-theme="dark"] .nav { background: rgba(15,17,23,0.97); } }
[data-theme="dark"] .compare-modal-content { background: var(--card-bg); }
[data-theme="dark"] .compare-modal-header { border-bottom-color: var(--border); }
[data-theme="dark"] .compare-info-bar { background: var(--bg-secondary); border-top-color: var(--border); }
[data-theme="dark"] .compare-close-btn { background: var(--bg-secondary); color: var(--text-light); }
[data-theme="dark"] .crop-action-btn { background: var(--card-bg); border-color: var(--border); color: var(--text-light); }
[data-theme="dark"] .crop-info-bar { background: var(--bg-secondary); border-color: var(--border); color: var(--text-light); }
[data-theme="dark"] .preset-btn { background: var(--card-bg); border-color: var(--border); color: var(--text-light); }
[data-theme="dark"] .preset-btn:hover { border-color: var(--primary); color: var(--primary); }
[data-theme="dark"] .preset-btn.selected { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
[data-theme="dark"] .template-btn { background: var(--card-bg); border-color: var(--border); color: var(--text-light); }
[data-theme="dark"] .template-btn:hover { border-color: var(--primary); }
[data-theme="dark"] .template-btn.selected { background: var(--primary-light); border-color: var(--primary); }
[data-theme="dark"] .auto-compress-label { color: var(--text-light); }
[data-theme="dark"] .result-dimensions { color: var(--text-lighter); }
[data-theme="dark"] .saving-bar-track { background: var(--border); }
[data-theme="dark"] .toast { background: var(--card-bg); color: var(--text); box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
[data-theme="dark"] .crop-hint { background: rgba(0,0,0,0.85); }
[data-theme="dark"] .compare-slider-handle { background: #e4e4e7; border-color: rgba(255,255,255,0.2); }
[data-theme="dark"] .btn-primary:disabled { background: #374151; color: #6B7280; }
[data-theme="dark"] .slider-group input[type="range"]::-webkit-slider-thumb { border-color: #e4e4e7; }
[data-theme="dark"] .slider-group input[type="range"]::-moz-range-thumb { border-color: #e4e4e7; }
[data-theme="dark"] .preview-area {
    background-image:
        linear-gradient(45deg, #2a2d3a 25%, transparent 25%),
        linear-gradient(-45deg, #2a2d3a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2a2d3a 75%),
        linear-gradient(-45deg, transparent 75%, #2a2d3a 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
[data-theme="dark"] .compare-container {
    background-image:
        linear-gradient(45deg, #2a2d3a 25%, transparent 25%),
        linear-gradient(-45deg, #2a2d3a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2a2d3a 75%),
        linear-gradient(-45deg, transparent 75%, #2a2d3a 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* RTL Support */
[data-theme="dark"] .select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
[data-theme="dark"] .lang-switcher {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[dir="rtl"] .toast { animation-name: toastInRTL; }
[dir="rtl"] .toast.removing { animation-name: toastOutRTL; }
@keyframes toastInRTL { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOutRTL { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-100%); opacity: 0; } }

[dir="rtl"] .compare-label-left {
    left: auto;
    right: 16px;
}
[dir="rtl"] .compare-label-right {
    right: auto;
    left: 16px;
}
[dir="rtl"] .image-badge {
    left: auto;
    right: 4px;
}
[dir="rtl"] .remove-btn {
    right: auto;
    left: 4px;
}
[dir="rtl"] .drag-grip {
    left: auto;
    right: 4px;
}
[dir="rtl"] .hero { text-align: center; }
[dir="rtl"] .trust-badges { justify-content: center; }
[dir="rtl"] .features { text-align: center; }
[dir="rtl"] .faq { text-align: center; }
[dir="rtl"] .lang-switcher {
    padding: 9px 12px 9px 28px;
    min-width: 90px;
}
[dir="rtl"] .select {
    background-position: left 10px center;
    padding-right: 12px;
    padding-left: 32px;
}
[dir="rtl"] .footer-grid {
    direction: ltr;
}

@media print {
    .header, .nav, .hamburger, .ad-container, .upload-area,
    .settings-panel, .preview-actions, .btn, .options-panel,
    .how-it-works, .features, .use-cases, .faq, .related-tools, .footer,
    .compare-modal { display: none !important; }
    .tool-card { box-shadow: none; border: 1px solid #ccc; }
    .preview-area { border: 1px solid #ccc; min-height: auto; }
    body { background: white; color: black; }
}