:root {
  --primary: #E17055;
  --primary-dim: rgba(225,112,85,0.12);
  --secondary: #FAB1A0;
  --accent: #0984E3;
  --accent-dim: rgba(9,132,227,0.12);
  --bg: #1A0F0A;
  --bg-input: rgba(14,8,4,0.9);
  --border: rgba(225,112,85,0.1);
  --border-hover: rgba(225,112,85,0.2);
  --text: #E2E8F0;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --transition: 250ms ease;
  --glass: rgba(26,15,10,0.65);
  --glass-border: rgba(225,112,85,0.08);
  --success: #10B981;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  min-height: 100vh; line-height: 1.6;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(225,112,85,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(9,132,227,0.03) 0%, transparent 50%);
}
.app { max-width: 1100px; margin: 0 auto; padding: 0 24px; display: flex; flex-direction: column; min-height: 100vh; }

.header { padding: 16px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.header h1 { font-size: 1.2rem; font-weight: 700; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: var(--radius-sm); border: none; font-family: var(--font); font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #D35400; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--primary-dim); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-full { width: 100%; justify-content: center; margin-top: 10px; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; text-decoration: underline; font-size: 0.85rem; }

.main { flex: 1; padding: 16px 0; display: flex; flex-direction: column; gap: 16px; }

.panel { background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; animation: fadeIn 0.3s ease; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 0.88rem; font-weight: 600; }
.panel-body { padding: 16px; }

/* Drop Zone */
.upload-section { display: flex; justify-content: center; padding: 40px 0; }
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 50px 40px; text-align: center; cursor: pointer; transition: all var(--transition); max-width: 500px; width: 100%; }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--primary); background: var(--primary-dim); }
.drop-icon { font-size: 3rem; margin-bottom: 10px; }
.drop-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 6px; }

/* Quality Controls */
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-label { font-size: 0.82rem; min-width: 120px; }
.slider { flex: 1; accent-color: var(--primary); }
.info-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.info-card { padding: 10px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); text-align: center; }
.info-label { display: block; font-size: 0.68rem; color: var(--text-muted); }
.info-value { display: block; font-size: 1rem; font-weight: 700; font-family: var(--mono); margin-top: 2px; }
.info-value.savings { color: var(--success); }
.info-value.optimal { color: var(--accent); }

/* Compare */
.compare-container { display: flex; position: relative; height: 400px; overflow: hidden; }
.compare-side { flex: 1; overflow: hidden; position: relative; }
.compare-side canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.side-label { position: absolute; top: 8px; padding: 3px 10px; border-radius: 8px; font-size: 0.68rem; font-weight: 600; }
.original-side .side-label { left: 8px; background: rgba(225,112,85,0.2); color: var(--primary); }
.webp-side .side-label { right: 8px; background: rgba(9,132,227,0.2); color: var(--accent); }
.compare-divider { position: absolute; top: 0; bottom: 0; width: 4px; background: var(--primary); cursor: col-resize; z-index: 10; left: 50%; transform: translateX(-50%); }
.divider-handle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--primary); color: #fff; padding: 4px 8px; border-radius: 12px; font-size: 0.72rem; pointer-events: none; }

/* Quality Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.grid-card { padding: 8px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); text-align: center; cursor: pointer; transition: all var(--transition); }
.grid-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.grid-card.active { border-color: var(--primary); background: var(--primary-dim); }
.grid-card canvas { width: 100%; border-radius: 4px; }
.grid-quality { font-size: 0.78rem; font-weight: 700; color: var(--primary); margin-top: 4px; }
.grid-size { font-size: 0.68rem; color: var(--text-dim); font-family: var(--mono); }

.footer { padding: 16px 0; text-align: center; font-size: 0.72rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: auto; }

.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
@media (max-width: 600px) { .info-row { grid-template-columns: repeat(2, 1fr); } .compare-container { height: 250px; } }
