:root {
    --bg-color: #f4f7fc;
    --card-bg: #ffffff;
    --primary-blue: #2563eb;
    --primary-dark: #1e3a5f;
    --text-dark: #0f172a;
    --text-gray: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* System font stack - no external font request, zero render-block */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg-color); color: var(--text-dark); line-height: 1.6; }
.container,
.wrap {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}
main.container, main.wrap { padding-top: 2rem; padding-bottom: 2rem; }

/* Hero Section */
.hero { text-align: center; background: var(--primary-blue); padding: 5rem 1rem; width: 100%; }
.hero-title { color: #ffffff; font-size: 2.5rem; font-weight: 800; margin-bottom: 0.75rem; line-height: 1.2; letter-spacing: -0.025em; }
.hero-sub { color: rgba(255, 255, 255, 0.9); font-size: 1.125rem; max-width: 700px; margin: 0 auto; }

@media (max-width: 600px) {
    .hero-title { font-size: 2rem; }
    .hero-sub { font-size: 1rem; }
}

/* Breadcrumb */
.breadcrumb { margin-bottom: 2rem; display: flex; align-items: center; gap: 0.5rem; }
.breadcrumb a { color: var(--primary-blue); text-decoration: none; font-weight: 500; font-size: 0.875rem; transition: color 0.2s; }
.breadcrumb a:hover { color: var(--primary-dark); text-decoration: underline; }
.breadcrumb span { color: var(--text-gray); font-size: 0.875rem; }

/* Tool Wrapper */
.tool-wrapper { background: var(--card-bg); border-radius: 20px; padding: 4rem; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05); margin-bottom: 3rem; border: 1px solid var(--border-color); }
.header { text-align: center; margin-bottom: 3rem; }
.header h1 { color: var(--primary-dark); font-size: 2.25rem; font-weight: 700; letter-spacing: -0.025em; margin-bottom: 0.75rem; }

/* Accessibility & Focus */
a:focus-visible, button:focus-visible, input:focus-visible, .drop-zone:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 8px; }

/* Upload Component */
#uploadState { display: block; animation: fadeIn 0.3s ease; }
.drop-zone { border: 2px dashed #94a3b8; border-radius: 16px; padding: 4rem 2rem; text-align: center; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); background: #f8fafc; display: block; position: relative; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary-blue); background: #eff6ff; }
.drop-zone-icon { width: 72px; height: 72px; background: #dbeafe; color: var(--primary-blue); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1.5rem; transition: transform 0.3s; }
.drop-zone:hover .drop-zone-icon { transform: translateY(-4px); }
.drop-zone-icon svg { width: 36px; height: 36px; }
.drop-zone-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--primary-dark); }
.drop-zone-text { color: var(--text-gray); font-size: 0.95rem; margin-bottom: 2.5rem; }

/* Buttons */
.btn { background: var(--primary-blue); color: white; border: none; padding: 0.6rem 1.25rem; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 0.95rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; transition: all 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.05); min-height: 44px; }
.btn:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: #ffffff; color: var(--text-dark); border: 1px solid var(--border-color); }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; border-color: #cbd5e1; }
.btn-danger { background: #ffffff; color: var(--error-color); border: 1px solid var(--border-color); }
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }

.badges { display: flex; justify-content: center; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }
.badge { background: #f1f5f9; color: var(--text-gray); font-size: 0.75rem; padding: 0.5rem 1rem; border-radius: 999px; display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; border: 1px solid var(--border-color); }
input[type="file"] { display: none; }

/* Settings Panel (For PDF/SVG/ICO options) */
.settings-panel { background: #f8fafc; border: 1px solid var(--border-color); border-radius: 12px; padding: 1.5rem; margin-top: 2rem; text-align: left; }
.settings-title { font-weight: 600; margin-bottom: 1rem; color: var(--text-dark); font-size: 1.1rem; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; }
.setting-group { display: flex; flex-direction: column; gap: 0.5rem; }
.setting-group label { font-size: 0.875rem; font-weight: 500; color: var(--text-gray); }
.setting-group select, .setting-group input { padding: 0.5rem; border-radius: 6px; border: 1px solid var(--border-color); font-family: inherit; min-height: 44px; }

/* Processing Dashboard */
#processingState { display: none; animation: fadeIn 0.3s ease; }
.processing-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); }
.processing-title { font-size: 1.25rem; font-weight: 700; color: var(--primary-dark); display: flex; align-items: center; gap: 0.5rem; }
.queue-stats { font-size: 0.875rem; color: var(--text-gray); font-weight: 500; }

/* Progress Cards */
.file-list { display: flex; flex-direction: column; gap: 1rem; max-height: 60vh; overflow-y: auto; padding-right: 0.5rem; }
.file-card { display: flex; align-items: center; padding: 1.25rem; border: 1px solid var(--border-color); border-radius: 12px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.05); transition: border-color 0.2s, box-shadow 0.2s; position: relative; overflow: hidden; contain: layout style; }
.file-card:hover { border-color: #cbd5e1; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
/* Explicit width/height + aspect-ratio prevents CLS when thumbnails load */
.file-thumb { width: 64px; height: 64px; aspect-ratio: 1 / 1; border-radius: 8px; object-fit: cover; background: #f1f5f9; flex-shrink: 0; border: 1px solid var(--border-color); }
.file-details { flex: 1; min-width: 0; margin-left: 1.5rem; margin-right: 1.5rem; }
.file-header-info { display: flex; justify-content: space-between; margin-bottom: 0.5rem; align-items: center; }
.file-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--primary-dark); }
.file-meta { font-size: 0.75rem; color: var(--text-gray); display: flex; gap: 0.5rem; align-items: center; }
.file-size-reduction { color: var(--success-color); font-weight: 600; }

.progress-container { display: flex; align-items: center; gap: 1rem; margin-top: 0.75rem; }
/* translateZ(0) promotes to compositor layer — avoids main-thread paint on width change */
.progress-bar-bg { flex: 1; background: #e2e8f0; height: 6px; border-radius: 999px; overflow: hidden; position: relative; transform: translateZ(0); }
.progress-bar-fill { background: var(--primary-blue); height: 100%; width: 0%; transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s; }
.progress-percent { font-size: 0.8rem; font-weight: 700; width: 3rem; text-align: right; color: var(--primary-dark); font-variant-numeric: tabular-nums; }
.status-text { font-size: 0.75rem; font-weight: 600; color: var(--primary-blue); margin-top: 0.25rem; display: block; }

/* Card Actions */
.file-actions { display: flex; gap: 0.5rem; align-items: center; flex-shrink: 0; }
.action-btn { width: 44px; height: 44px; background: #ffffff; border: 1px solid var(--border-color); color: var(--text-gray); cursor: pointer; border-radius: 8px; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.action-btn:hover { background: #f1f5f9; color: var(--error-color); border-color: #cbd5e1; }
.btn-download-single { display: none; background: var(--success-color); color: white; border-color: var(--success-color); width: auto; padding: 0.35rem 0.85rem; font-weight: 600; font-size: 0.875rem; border-radius: 8px; align-items: center; gap: 0.35rem; text-decoration: none; cursor: pointer; border: 1px solid var(--success-color); transition: all 0.2s; min-height: 44px; }
.btn-download-single.ready { display: inline-flex; animation: fadeIn 0.3s ease; }
.btn-download-single:hover { background: #059669; }

.bottom-controls { display: flex; justify-content: space-between; margin-top: 2rem; border-top: 1px solid var(--border-color); padding-top: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.bottom-controls .group { display: flex; gap: 1rem; }

/* SEO & Content Sections — content-visibility skips off-screen rendering (LCP boost) */
.seo-section { background: var(--card-bg); border-radius: 20px; padding: 4rem; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); border: 1px solid var(--border-color); margin-bottom: 2rem; content-visibility: auto; contain-intrinsic-size: 0 500px; }
.seo-section h2 { color: var(--primary-dark); margin-bottom: 1.5rem; font-size: 1.875rem; font-weight: 700; letter-spacing: -0.025em; }
.seo-section h3 { color: var(--primary-dark); margin-top: 2.5rem; margin-bottom: 1.25rem; font-size: 1.5rem; font-weight: 600; }
.seo-section p { color: var(--text-gray); margin-bottom: 1.5rem; font-size: 1.05rem; }
.seo-section ul, .seo-section ol { color: var(--text-gray); margin-bottom: 1.5rem; padding-left: 1.5rem; }
.seo-section li { margin-bottom: 0.5rem; }

/* FAQ */
.faq-list { margin-top: 2rem; content-visibility: auto; contain-intrinsic-size: 0 300px; }
.faq-item { margin-bottom: 1.5rem; padding: 1.5rem; border-radius: 12px; background: #f8fafc; border: 1px solid var(--border-color); }
.faq-question { font-weight: 700; font-size: 1.15rem; margin-bottom: 0.75rem; color: var(--primary-dark); }
.faq-answer { color: var(--text-gray); margin: 0; }

/* Toast Notifications */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { background: var(--primary-dark); color: white; padding: 1rem 1.5rem; border-radius: 8px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); font-weight: 500; font-size: 0.9rem; animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: center; gap: 0.75rem; }
.toast.success { background: var(--success-color); }
.toast.error { background: var(--error-color); }
/* Fixed: opacity must be a separate property, not a transform function */
@keyframes toastIn { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile Optimization */
@media (max-width: 600px) {
    .tool-wrapper { padding: 1.5rem; }
    .drop-zone { padding: 2.5rem 1rem; }
    .file-card { flex-direction: column; align-items: flex-start; padding: 1rem; gap: 1rem; position: relative; }
    .file-details { margin: 0; width: 100%; }
    .file-actions { position: absolute; top: 1rem; right: 1rem; }
    .btn-download-single { width: 100%; margin-top: 0.5rem; justify-content: center; padding: 0.6rem; }
    .bottom-controls { flex-direction: column; }
    .bottom-controls .group { flex-direction: column; width: 100%; }
    .bottom-controls .btn { width: 100%; }
    .seo-section { padding: 1.5rem; }
}

/* Screen reader only utility */
/* Screen reader only utility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }

/* Hub Page Specific Grid Styles */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; margin-bottom: 4rem; }
/* will-change: transform declared only on hover to avoid memory overhead on all cards at once */
.tool-card { background: var(--card-bg); border-radius: 12px; padding: 2rem; text-decoration: none; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); transition: transform 0.2s, box-shadow 0.2s; display: flex; flex-direction: column; align-items: center; text-align: center; color: inherit; border: 1px solid var(--border-color); contain: layout style; }
.tool-card:hover { transform: translateY(-4px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); border-color: var(--primary-blue); will-change: transform; }
.tool-icon { width: 64px; height: 64px; background: #eff6ff; color: var(--primary-blue); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 1.5rem; }
.tool-icon svg { width: 32px; height: 32px; }
.tool-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--primary-dark); }
.tool-desc { color: var(--text-gray); font-size: 0.875rem; margin-bottom: 1.5rem; flex-grow: 1; }
.tool-btn { background: var(--primary-blue); color: white; padding: 0.75rem 1rem; border-radius: 8px; font-weight: 500; width: 100%; transition: background 0.2s; }
.tool-card:hover .tool-btn { background: var(--primary-dark); }

/* Large Desktop Optimization */
@media (min-width: 1600px) {
    .container,
    .wrap {
        max-width: 1360px;
    }
}
