*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #6366f1; --primary-hover: #4f46e5; --primary-light: #eef2ff;
  --bg: #f8fafc; --surface: #ffffff; --text: #1e293b; --text-muted: #64748b;
  --border: #e2e8f0; --success: #22c55e; --radius: 12px;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

/* ===== NAV ===== */
.nav { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.nav-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 1.25rem; }
.nav-logo { font-weight: 800; font-size: 1.3rem; color: var(--primary); text-decoration: none; display: flex; align-items: center; gap: 0.4rem; }
.nav-logo:hover { opacity: 0.85; }
.nav-right { display: flex; align-items: center; gap: 0.75rem; }
.nav-link { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; padding: 0.4rem 0.75rem; border-radius: 8px; transition: all 0.15s; text-decoration: none; }
.nav-link:hover { color: var(--primary); background: var(--primary-light); }
.nav-tools-btn { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 0.5rem 1rem; font-size: 0.9rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 0.4rem; transition: all 0.2s; }
.nav-tools-btn:hover { background: var(--primary-hover); }
.nav-tools-btn svg { width: 14px; height: 14px; transition: transform 0.2s; }
.nav-tools-btn.active { background: var(--primary-hover); }
.nav-tools-btn.active svg { transform: rotate(180deg); }

/* ===== MEGA MENU ===== */
.mega-overlay { display: none; position: fixed; top: 56px; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,0.3); z-index: 150; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.mega-menu { display: none; position: absolute; top: 56px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 12px 40px rgba(0,0,0,0.12); z-index: 200; }
.mega-inner { max-width: 1200px; margin: 0 auto; padding: 2rem 1.25rem; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2rem; }
.mega-cat-title { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--primary); margin-bottom: 0.75rem; }
.mega-link { display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem 0.6rem; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 0.88rem; font-weight: 500; transition: all 0.15s; }
.mega-link:hover { background: var(--primary-light); color: var(--primary); }
.mega-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.mega-icon.compress { background: #dbeafe; }
.mega-icon.convert { background: #fce7f3; }
.mega-icon.edit { background: #d1fae5; }
.mega-icon.create { background: #fef3c7; }

@media (max-width: 768px) {
  .mega-inner { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; padding: 1.25rem; }
  .nav-link { display: none; }
}
@media (max-width: 480px) {
  .mega-inner { grid-template-columns: 1fr; }
}

/* ===== LAYOUT ===== */
.container { max-width: 800px; margin: 0 auto; padding: 2rem 1rem; }
h1 { font-size: 2rem; margin-bottom: 0.5rem; font-weight: 800; }
h2 { font-size: 1.4rem; margin: 1.5rem 0 0.5rem; font-weight: 700; }
p { margin-bottom: 1rem; color: var(--text-muted); }

/* ===== HERO (homepage) ===== */
.hero { text-align: center; padding: 3rem 1rem 1rem; }
.hero h1 { font-size: 2.5rem; margin-bottom: 0.75rem; }
.hero p { font-size: 1.1rem; max-width: 550px; margin: 0 auto 2rem; }
.tools-grid { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem 3rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.tool-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center; text-decoration: none; color: var(--text); transition: all 0.2s; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.tool-card:hover { border-color: var(--primary); box-shadow: 0 4px 16px rgba(99,102,241,0.12); transform: translateY(-2px); }
.tool-card .tool-icon { font-size: 2rem; width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; margin-bottom: 0.25rem; }
.tool-card .tool-name { font-weight: 700; font-size: 0.95rem; }
.tool-card .tool-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }
.tool-icon.blue { background: #dbeafe; }
.tool-icon.pink { background: #fce7f3; }
.tool-icon.green { background: #d1fae5; }
.tool-icon.yellow { background: #fef3c7; }
.tool-icon.purple { background: #ede9fe; }
.tool-icon.orange { background: #ffedd5; }

/* ===== AD PLACEHOLDER ===== */
.ad-slot { background: var(--border); border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; margin: 1.5rem 0; min-height: 90px; display: flex; align-items: center; justify-content: center; }

/* ===== DROPZONE ===== */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 3rem 1.5rem; text-align: center; cursor: pointer; transition: all 0.2s; background: var(--surface); }
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-light); }
.dropzone-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.dropzone p { margin: 0; }
.dropzone input[type="file"] { display: none; }

/* ===== CONTROLS ===== */
.controls { margin: 1.5rem 0; display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.controls label { font-weight: 600; font-size: 0.9rem; }
.controls select, .controls input[type="number"] { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.9rem; background: var(--surface); }

/* ===== PREVIEW ===== */
.preview-area { display: none; margin: 1.5rem 0; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.preview-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.preview-card img { max-width: 100%; max-height: 250px; border-radius: 8px; object-fit: contain; }
.preview-card .label { font-weight: 600; margin-bottom: 0.5rem; font-size: 0.9rem; }
.preview-card .size { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.5rem; }
.savings { text-align: center; padding: 0.75rem; background: #f0fdf4; border-radius: 8px; color: #16a34a; font-weight: 600; margin-top: 1rem; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.7rem 1.5rem; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-download { background: var(--success); color: #fff; font-size: 1.05rem; padding: 0.8rem 2rem; box-shadow: 0 4px 14px rgba(34,197,94,0.3); }
.btn-download:hover { background: #16a34a; box-shadow: 0 6px 20px rgba(34,197,94,0.4); transform: translateY(-1px); }
@keyframes pulse-download { 0%,100%{box-shadow:0 4px 14px rgba(34,197,94,0.3)} 50%{box-shadow:0 4px 24px rgba(34,197,94,0.5)} }
.btn-download.ready { animation: pulse-download 2s ease-in-out 3; }
.actions { display: flex; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }

/* ===== LOADER ===== */
.loader { display: none; text-align: center; padding: 2rem; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 0.5rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== PROGRESS BAR ===== */
.progress-wrap { display: none; margin: 1rem 0; }
.progress-bar { width: 100%; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--success)); border-radius: 4px; transition: width 0.3s ease; }
.progress-text { text-align: center; font-size: 0.85rem; color: var(--text-muted); margin-top: 0.4rem; font-weight: 600; }

/* ===== SEO CONTENT ===== */
.seo-content { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.seo-content h2 { color: var(--text); }
.seo-content p { font-size: 0.95rem; }

/* ===== RELATED TOOLS ===== */
.related-tools { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.related-tools h2 { font-size: 1.3rem; margin-bottom: 1rem; color: var(--text); }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; }
.related-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; text-align: center; text-decoration: none; color: var(--text); transition: all 0.2s; }
.related-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(99,102,241,0.1); transform: translateY(-2px); }
.related-card .rc-icon { font-size: 1.5rem; margin-bottom: 0.4rem; }
.related-card .rc-name { font-weight: 600; font-size: 0.88rem; }

/* ===== FOOTER ===== */
.footer { text-align: center; padding: 2rem 1rem; color: var(--text-muted); font-size: 0.85rem; border-top: 1px solid var(--border); margin-top: 3rem; }

@media (max-width: 600px) {
  .preview-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
  .hero h1 { font-size: 1.75rem; }
  .dropzone { padding: 2rem 1rem; }
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
}
