:root {
  --accent1:#2563eb;
  --accent2:#7c3aed;
  --bg:#f9fafb;
  --card-glass:rgba(255,255,255,0.8);
  --border:rgba(209,213,219,0.5);
  --soft:#6b7280;
  --text:#111827;
}
[data-theme="dark"] {
  --bg:#0f172a;
  --card-glass:rgba(30,41,59,0.82);
  --border:rgba(148,163,184,0.4);
  --soft:#9ca3af;
  --text:#e5e7eb;
}

/* ===== BODY ===== */
body {
  margin:0;
  font-family:'Inter',sans-serif;
  background:
    radial-gradient(circle at top left,rgba(37,99,235,0.2),transparent 60%),
    radial-gradient(circle at bottom right,rgba(124,58,237,0.25),transparent 65%),
    var(--bg);
  color:var(--text);
  overflow-x:hidden;
}

/* ===== HERO ===== */
main {
  max-width:1200px;
  margin:0 auto 80px;
  padding:110px 20px 60px;
}
.hero {
  text-align:center;
  margin-bottom:30px;
}
.hero h1 {
  font-size:2.3rem;
  font-weight:800;
  background:linear-gradient(90deg,var(--accent1),var(--accent2));
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
  margin:0 0 8px;
}
.hero p {
  color:var(--soft);
  max-width:700px;
  margin:auto;
  line-height:1.6;
  font-size:1rem;
}

/* ===== GLASS CARD ===== */
.glass-card {
  background:var(--card-glass);
  border:1px solid var(--border);
  border-radius:16px;
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
  box-shadow:0 8px 20px rgba(0,0,0,0.05);
  transition:.25s;
}
.glass-card:hover {
  transform:translateY(-2px);
  box-shadow:0 12px 32px rgba(37,99,235,0.15);
}

/* ===== TOP SECTION ===== */
.top-row {
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:20px;
  margin-bottom:18px;
}
@media(max-width:900px){.top-row{grid-template-columns:1fr;}}

/* ===== UPLOAD CARD ===== */
.upload-card {padding:18px;}
.upload-inner {
  border:1.5px dashed rgba(148,163,184,0.6);
  border-radius:12px;
  padding:22px 16px;
  text-align:center;
  transition:.25s;
}
.upload-inner.dragover {
  border-color:var(--accent1);
  background:rgba(37,99,235,0.08);
}
.upload-icon {
  width:40px;height:40px;margin:0 auto 10px;
  display:flex;align-items:center;justify-content:center;
  border-radius:10px;
  background:linear-gradient(135deg,var(--accent1),var(--accent2));
  color:#fff;font-size:1.2rem;
}
.upload-inner h2 {font-size:1rem;font-weight:700;margin-bottom:6px;}
.upload-inner p {font-size:.85rem;color:var(--soft);margin:0 0 8px;}
.btn-primary {
  border:none;
  border-radius:999px;
  padding:8px 16px;
  font-size:.82rem;
  background:linear-gradient(90deg,var(--accent1),var(--accent2));
  color:#fff;
  font-weight:600;
  cursor:pointer;
}
.btn-primary:hover {filter:brightness(1.1);}
.upload-note {
  display:block;
  margin-top:8px;
  font-size:.75rem;
  color:var(--soft);
}

/* ===== INFO CARD ===== */
/* ===== INFO CARD (Enhanced) ===== */
.info-card {
  padding:28px 26px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  background:linear-gradient(145deg,rgba(255,255,255,0.9),rgba(245,247,255,0.7));
  border-radius:18px;
  border:1px solid rgba(209,213,219,0.5);
  box-shadow:0 8px 28px rgba(37,99,235,0.08);
  transition:.3s ease;
}
[data-theme="dark"] .info-card {
  background:linear-gradient(145deg,rgba(30,41,59,0.9),rgba(17,24,39,0.8));
  box-shadow:0 8px 24px rgba(0,0,0,0.35);
  border:1px solid rgba(148,163,184,0.25);
}

.info-card:hover {
  transform:translateY(-3px);
  box-shadow:0 14px 40px rgba(37,99,235,0.12);
}

.info-title {
  font-weight:800;
  font-size:1.1rem;
  background:linear-gradient(90deg,var(--accent1),var(--accent2));
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
  margin-bottom:10px;
  letter-spacing:-0.02em;
}

.info-text {
  font-size:.9rem;
  color:var(--soft);
  line-height:1.65;
  margin-bottom:14px;
}

.info-tags {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:auto;
}
.info-tags span {
  font-size:.78rem;
  padding:6px 12px;
  border-radius:999px;
  font-weight:600;
  background:linear-gradient(90deg,rgba(37,99,235,0.08),rgba(124,58,237,0.1));
  border:1px solid rgba(148,163,184,0.4);
  color:var(--accent1);
  transition:.25s;
}
.info-tags span:hover {
  background:linear-gradient(90deg,var(--accent1),var(--accent2));
  color:#fff;
  transform:translateY(-1px);
}


/* ===== SETTINGS PANEL (COMPACT FIX) ===== */
.settings-card {
  background:var(--card-glass);
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:0 8px 25px rgba(0,0,0,0.05);
  padding:12px 14px 10px;
  margin-bottom:20px;
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
}
.settings-inner {
  display:flex;
  flex-direction:column;
  gap:8px;
}
.settings-group {
  display:flex;
  flex-direction:column;
  gap:4px;
}
.settings-group label {
  font-size:.8rem;
  font-weight:600;
  display:flex;
  justify-content:space-between;
}
.settings-group small {
  font-size:.72rem;
  color:var(--soft);
  line-height:1.3;
  margin-top:-2px;
}
input[type=range]{
  width:100%;
  accent-color:var(--accent1);
  margin:4px 0;
}
.resize-row {
  display:flex;
  gap:6px;
  align-items:center;
}
.resize-row input {
  width:100%;
  padding:6px 8px;
  border-radius:8px;
  border:1px solid rgba(148,163,184,0.5);
  background:rgba(255,255,255,0.5);
  font-size:.78rem;
  color:var(--text);
}
[data-theme="dark"] .resize-row input {
  background:rgba(30,41,59,0.6);
}
.resize-row span {
  color:var(--soft);
  font-weight:600;
}
.settings-actions {
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  justify-content:flex-end;
  margin-top:4px;
}
.btn-ghost,.btn-outline {
  border:none;
  border-radius:999px;
  padding:6px 12px;
  font-size:.75rem;
  cursor:pointer;
  font-weight:600;
  transition:.25s;
}
.btn-ghost {
  background:linear-gradient(90deg,var(--accent1),var(--accent2));
  color:#fff;
}
.btn-outline {
  border:1px solid rgba(148,163,184,0.6);
  background:transparent;
  color:var(--soft);
}
.btn-outline:hover {background:rgba(37,99,235,0.08);color:var(--accent1);}
.settings-stats {
  margin-top:6px;
  font-size:.74rem;
  color:var(--soft);
}
.progress-bar {
  width:100%;
  height:4px;
  border-radius:999px;
  background:rgba(229,231,235,0.5);
  overflow:hidden;
}
#progressInner {
  width:0%;
  height:100%;
  background:linear-gradient(90deg,var(--accent1),var(--accent2));
  transition:width .3s;
}

/* ===== RESULTS GRID ===== */
.results-section {margin-top:14px;}
.results-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
  gap:6px;
  margin-bottom:8px;
  font-size:.82rem;
  color:var(--soft);
}
.results-grid {
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(210px,1fr));
  gap:14px;
}
.img-card {
  background:var(--card-glass);
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:0 6px 18px rgba(0,0,0,0.05);
  overflow:hidden;
}
.img-thumb {
  background:rgba(0,0,0,0.05);
  height:200px;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
.img-thumb canvas {
  width:100%;
  height:100%;
  object-fit:contain;
  border-radius:8px;
}
.img-meta {
  padding:8px 10px 5px;
  font-size:.76rem;
  color:var(--soft);
}
.img-name {
  font-size:.8rem;
  font-weight:600;
  color:var(--text);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  margin-bottom:3px;
}
.meta-row {
  display:flex;
  justify-content:space-between;
  font-size:.74rem;
}
.img-actions {
  display:flex;
  flex-wrap:wrap;
  gap:5px;
  padding:7px;
  border-top:1px solid rgba(148,163,184,0.25);
  justify-content:center;
}
.btn-chip {
  flex:1 1 calc(33% - 5px);
  font-size:.72rem;
  padding:5px 8px;
  border-radius:8px;
  border:none;
  cursor:pointer;
  font-weight:600;
}
.btn-chip.primary {
  background:linear-gradient(90deg,var(--accent1),var(--accent2));
  color:#fff;
}
.btn-chip.secondary {
  background:rgba(37,99,235,0.1);
  color:var(--accent1);
}
.btn-chip.danger {
  background:rgba(248,113,113,0.14);
  color:#ef4444;
}

/* ===== RESPONSIVE FIX ===== */
@media(max-width:700px){
  main{padding:90px 14px 60px;}
  .hero h1{font-size:1.8rem;}
  .hero p{font-size:.9rem;}
  .settings-card{padding:10px 12px;}
  .settings-group label{font-size:.78rem;}
  .resize-row input{padding:5px 7px;font-size:.76rem;}
  .settings-actions{justify-content:flex-start;}
  .btn-ghost,.btn-outline{padding:5px 10px;font-size:.72rem;}
  .results-grid{grid-template-columns:repeat(2,minmax(160px,1fr));gap:10px;}
  .img-thumb{height:230px;}
}
@media(max-width:450px){
  .results-grid{grid-template-columns:1fr;}
  .img-thumb{height:240px;}
  .settings-card{padding:8px 10px;}
}

/* ===== EMPTY STATE ===== */
.empty-state {
  grid-column:1/-1;
  text-align:center;
  padding:26px 16px;
  border:1.5px dashed var(--border);
  border-radius:14px;
  color:var(--soft);
  font-size:.83rem;
}

/* ===== STICKY SETTINGS PANEL (Mobile View) ===== */
@media(max-width:800px){
  .settings-card {
    position:sticky;
    top:68px; /* height of header */
    z-index:40;
    border-radius:0 0 18px 18px;
    box-shadow:0 2px 14px rgba(0,0,0,0.1);
    background:rgba(255,255,255,0.85);
    backdrop-filter:blur(14px);
    -webkit-backdrop-filter:blur(14px);
    margin-bottom:10px;
  }
  [data-theme="dark"] .settings-card {
    background:rgba(17,24,39,0.85);
    box-shadow:0 2px 14px rgba(0,0,0,0.4);
  }

  /* When scrolling, slightly shrink for modern feel */
  .settings-card.compact {
    padding:8px 10px 8px;
    box-shadow:0 2px 8px rgba(0,0,0,0.15);
  }
}


/* ===== UNIVERSAL STICKY SETTINGS FIX ===== */
.settings-card {
  position: sticky;
  top: 68px; /* below your header */
  z-index: 40;
}

/* Keep same base styles (your compact structure) */
@media(max-width:800px){
  .settings-card {
    position: sticky;
    top: 68px;
    z-index: 40;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 2px 14px rgba(0,0,0,0.1);
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    margin-bottom: 10px;
  }
  [data-theme="dark"] .settings-card {
    background: rgba(17,24,39,0.85);
    box-shadow: 0 2px 14px rgba(0,0,0,0.4);
  }
  .settings-card.compact {
    padding: 8px 10px 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }
}
/* 🔹 custom dropdown styling */
.format-select {
  appearance:none;
  background:var(--card-glass);
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 36px 10px 12px;
  font-size:.95rem;
  font-weight:600;
  color:var(--text);
  outline:none;
  cursor:pointer;
  background-image:url('data:image/svg+xml;utf8,<svg fill="white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg>');
  background-repeat:no-repeat;
  background-position:right 12px center;
  background-size:18px;
  transition:all .2s ease;
}
.format-select:hover{
  border-color:var(--accent1);
  background-color:rgba(37,99,235,0.1);
}
#bgSection{
  transition:all .25s ease;
  overflow:hidden;
}
#bgSection.hide{
  max-height:0;
  opacity:0;
  margin:0;
  padding:0;
}

/* ——— Layout ——— */
.settings-card{
  background:var(--card-glass);border:1px solid var(--border);
  border-radius:14px;padding:12px 14px;margin-top:14px;
  box-shadow:0 4px 14px rgba(0,0,0,0.05);backdrop-filter:blur(10px);
}
.settings-inner{display:flex;flex-direction:column;gap:10px}
.settings-group{display:flex;flex-direction:column;gap:4px}
.row-flex{display:flex;flex-wrap:wrap;align-items:center;gap:10px}
.col{display:flex;flex-direction:column;gap:2px;min-width:90px}
.col.quality{flex:1}.col.small{flex:none}
select,input[type="number"],input[type="color"]{
  background:var(--card);border:1px solid var(--border);
  border-radius:8px;padding:5px 8px;font-size:.8rem;color:var(--text);
}
input[type="number"]{width:90px}
input[type="range"]{width:100%;accent-color:var(--accent1)}
.accent{color:var(--accent1);font-weight:700}
.color-chip{display:flex;align-items:center;gap:8px;border:1px solid var(--border);
  border-radius:999px;padding:3px 10px;background:var(--card)}
.color-swatch{width:18px;height:18px;border-radius:50%;border:1px solid var(--border)}
.settings-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:4px}
.progress-bar{height:5px;background:var(--border);border-radius:4px;overflow:hidden}
#progressInner{height:100%;width:0%;background:linear-gradient(90deg,#2563eb,#7c3aed);
  transition:width .25s ease}
.settings-stats{display:flex;flex-direction:column;gap:3px;margin-top:4px}
#overallStats{font-size:.74rem;color:var(--soft)}
.limit-note{font-size:.75rem;color:var(--soft);text-align:right;margin-top:2px}
@media(max-width:700px){.settings-card{padding:10px 12px}.settings-actions{justify-content:center}}

/* ——— Grid Cards ——— */
.img-card{display:flex;flex-direction:column;background:var(--card-glass);
  border:1px solid var(--border);border-radius:12px;overflow:hidden;
  box-shadow:0 4px 12px rgba(0,0,0,0.04);transition:.15s ease}
.img-card:hover{transform:translateY(-2px);box-shadow:0 6px 18px rgba(0,0,0,0.06)}
.img-thumb{width:100%;background:var(--card);display:flex;align-items:center;
  justify-content:center;height:120px;border-bottom:1px solid var(--border)}
.img-thumb canvas{max-width:100%;max-height:100%;object-fit:contain}
.img-meta{padding:8px 10px;display:flex;flex-direction:column;gap:2px;font-size:.8rem}
.img-title{display:flex;justify-content:space-between;font-weight:600}
.file-name{color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:140px}
.file-size{color:var(--soft);font-weight:500}
.img-sub{display:flex;justify-content:space-between;color:var(--soft);font-size:.75rem}
.img-actions{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-top:1px solid var(--border)}
.btn-chip.mini{font-size:.74rem;padding:3px 8px;border-radius:6px}

/* ——— Working Dialog ——— */
.work-dialog{position:fixed;inset:0;background:rgba(0,0,0,0.45);backdrop-filter:blur(6px);
  display:flex;align-items:center;justify-content:center;z-index:999}
.hidden{display:none}
.dialog-box{background:var(--card-glass);padding:20px 26px;border-radius:14px;
  border:1px solid var(--border);box-shadow:0 10px 25px rgba(0,0,0,0.15);
  text-align:center;color:var(--text);min-width:220px}
.spinner{width:32px;height:32px;border:3px solid var(--border);
  border-top-color:var(--accent1);border-radius:50%;margin:0 auto 10px;
  animation:spin .9s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}
.dialog-text{font-size:.85rem;font-weight:500;color:var(--text)}


main { padding-bottom:40px; }
.hero { margin-bottom:10px; }

/* --- Desktop Layout --- */
.tool-grid {
  display:grid;
  grid-template-columns:1.15fr 0.85fr;
  gap:18px;
  align-items:stretch;
  min-height:calc(100vh - 220px);
}
.glass-card {
  display:flex;
  flex-direction:column;
  padding:18px;
  border-radius:16px;
  background:var(--card-glass);
  border:1px solid var(--border);
  box-shadow:0 8px 24px rgba(0,0,0,0.05);
}

/* --- Preview Panel --- */
.preview-shell {
  flex:1;
  display:flex;
  flex-direction:column;
  gap:12px;
  overflow:auto;
}
.preview-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}
.preview-cell {
  background:var(--card-glass);
  border:1px solid var(--border);
  border-radius:14px;
  padding:10px;
  box-shadow:0 6px 18px rgba(0,0,0,0.04);
  transition:background .3s,border .3s;
}
.preview-cell b {
  font-size:.9rem;
  color:var(--soft);
  display:block;
  margin-bottom:8px;
}
.preview-cell img {
  max-width:100%;
  height:auto;
  display:block;
  border-radius:8px;
}
.svg-box {
  background:var(--card-glass);
  border:1px dashed var(--border);
  border-radius:10px;
  overflow:hidden;
  min-height:240px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--soft);
  transition:background .3s,border .3s,color .3s;
}
.empty-state {
  color:var(--soft);
  text-align:center;
  padding:22px;
  transition:color .3s;
}
.code-box {
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--card-glass);
  padding:10px;
  box-shadow:0 6px 18px rgba(0,0,0,0.04);
  transition:background .3s,border .3s;
}
.code-box textarea {
  width:100%;
  min-height:170px;
  border:none;
  outline:none;
  background:transparent;
  resize:vertical;
  font-family:ui-monospace,Menlo,Consolas,monospace;
  font-size:.8rem;
  color:var(--text);
  transition:color .3s;
}

/* --- Settings Panel --- */
.settings-inner {
  display:flex;
  flex-direction:column;
  gap:12px;
  flex:1;
}
.upload-area {
  border:2px dashed var(--border);
  border-radius:12px;
  padding:20px;
  text-align:center;
  background:rgba(148,163,184,.08);
  transition:.2s;
}
.upload-area.dragover {
  border-color:var(--accent1);
  background:rgba(37,99,235,.08);
}
.preset-row {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
.chip {
  border:1px solid var(--border);
  border-radius:999px;
  padding:6px 12px;
  font-size:.82rem;
  cursor:pointer;
  background:var(--card-glass);
  color:var(--soft);
  transition:.2s;
  box-shadow:0 4px 12px rgba(0,0,0,.04);
}
.chip.active {
  background:linear-gradient(90deg,var(--accent1),var(--accent2));
  color:#fff;
  border-color:transparent;
  box-shadow:0 6px 16px rgba(124,58,237,.18);
}
.compact-options {
  display:flex;
  flex-wrap:wrap;
  gap:14px;
  align-items:center;
}
.slider {
  display:flex;
  align-items:center;
  gap:8px;
  flex:1 1 210px;
}
.slider label {
  font-size:.8rem;
  color:var(--soft);
  white-space:nowrap;
}
.slider input[type=range] {
  flex:1;
  accent-color:var(--accent1);
}
.slider span {
  font-size:.75rem;
  color:var(--accent1);
  width:34px;
  text-align:right;
}
.settings-actions {
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:4px;
}
.settings-actions .btn-primary,
.settings-actions .btn-outline,
.settings-actions .btn-ghost {
  min-width:120px;
}

/* --- Mobile Layout: stack + sticky settings --- */
@media(max-width:900px){
  .tool-grid {
    display:flex;
    flex-direction:column;
  }
  .settings-card {
    order:1;
    position:sticky;
    top:60px;
    z-index:10;
    background:var(--card-glass);
    backdrop-filter:blur(12px);
    box-shadow:0 4px 10px rgba(0,0,0,0.05);
  }
  .preview-card {
    order:2;
    margin-top:10px;
  }
  .preview-grid {
    grid-template-columns:1fr;
  }
}

/* Placeholder header for layout injection */
header[style] {
  position:sticky;
  top:0;
  z-index:50;
}
.settings-card.compact {padding:14px 18px;}
.settings-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(300px,1fr));
  gap:20px;
  align-items:start;
}
.settings-col {display:flex;flex-direction:column;gap:10px;}
.settings-group,
.settings-sub {display:flex;flex-direction:column;gap:6px;}
.settings-group label,
.settings-sub label {font-weight:600;font-size:.8rem;color:var(--text);}
.settings-group select,
.settings-sub input[type=number],
.settings-sub input[type=text],
.settings-group input[type=range]{
  width:100%;padding:6px 8px;border:1px solid var(--border);
  background:var(--input-bg);border-radius:6px;font-size:.82rem;
}
.pair{display:flex;gap:8px;}
.pair input{flex:1;}
.inline{display:flex;align-items:center;gap:6px;font-size:.78rem;color:var(--soft);}
.small-row{margin-top:4px;}
.tiny-row{margin-top:2px;}
.compact-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:6px;}
.settings-stats.mini{margin-top:4px;}

/* compact settings polish */
.settings-card.compact .tiny-row input[type="text"],
.settings-card.compact .text-input {
  width:100%;
  padding:6px 8px;
  border:1px solid var(--border);
  background:var(--input-bg);
  border-radius:6px;
  font-size:.82rem;
  line-height:1.2;
}

/* optional: unify all inputs in compact card just in case */
.settings-card.compact select,
.settings-card.compact input[type="number"],
.settings-card.compact input[type="text"],
.settings-card.compact input[type="range"]{
  border:1px solid var(--border);
  background:var(--input-bg);
  border-radius:6px;
}



