/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0b0d14;
  --surface:    #111421;
  --surface-2:  #181c2e;
  --border:     rgba(255,255,255,0.07);
  --border-hl:  rgba(120,100,255,0.45);
  --accent:     #7b61ff;
  --accent-2:   #00d4aa;
  --accent-glow:rgba(123,97,255,0.35);
  --text:       #e8eaf6;
  --text-muted: #8b8fa8;
  --text-dim:   #4f5370;
  --red:        #ff5c5c;
  --green:      #00d4aa;
  --radius:     16px;
  --radius-sm:  10px;
  --shadow:     0 8px 40px rgba(0,0,0,0.55);
  font-family: 'Inter', system-ui, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ─── Background orbs ───────────────────────────────────────── */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}
.orb-1 { width: 600px; height: 600px; background: #7b61ff; top: -200px; left: -150px; }
.orb-2 { width: 500px; height: 500px; background: #00d4aa; bottom: -150px; right: -100px; }
.orb-3 { width: 300px; height: 300px; background: #ff61cb; top: 40%; left: 55%; }

/* ─── Layout ─────────────────────────────────────────────────── */
.layout {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 16px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Header ──────────────────────────────────────────────────── */
.header { text-align: center; padding: 24px 0 8px; }
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.logo-icon {
  font-size: 2rem;
  color: var(--accent);
  filter: drop-shadow(0 0 16px var(--accent));
  line-height: 1;
}
.logo-text {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #7b61ff 0%, #00d4aa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
.header-subtitle { color: var(--text-muted); font-size: 0.95rem; }

/* ─── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  transition: border-color 0.2s;
}
.card:hover { border-color: rgba(255,255,255,0.1); }

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ─── Drop Zone ───────────────────────────────────────────────── */
.upload-card { padding: 0; overflow: hidden; }

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 56px 32px;
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s;
  text-align: center;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(123,97,255,0.05);
}
.drop-zone.drag-over .drop-icon { transform: translateY(-6px) scale(1.1); }

.drop-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 8px;
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1);
  filter: drop-shadow(0 0 12px var(--accent-glow));
}
.drop-icon .ti {
  font-size: 56px;
  line-height: 1;
}

.drop-title { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.drop-sub { color: var(--text-muted); font-size: 0.9rem; }
.browse-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.15s;
}
.browse-link:hover { opacity: 0.75; }
.drop-formats { font-size: 0.78rem; color: var(--text-dim); margin-top: 4px; }

/* ─── File Preview ────────────────────────────────────────────── */
.file-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  position: relative;
}
.file-preview img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.file-meta { display: flex; flex-direction: column; gap: 4px; }
.file-name { font-weight: 500; font-size: 0.95rem; color: var(--text); }
.file-size { font-size: 0.82rem; color: var(--text-muted); }
.btn-clear {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-clear:hover { color: var(--red); border-color: var(--red); }

/* ─── Settings ────────────────────────────────────────────────── */
.settings-grid { display: flex; flex-direction: column; gap: 20px; margin-bottom: 24px; }

.field { display: flex; flex-direction: column; gap: 8px; }

.field-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field-badge {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 99px;
  letter-spacing: 0.3px;
  min-width: 60px;
  text-align: center;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.slider-min, .slider-max {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  outline: none;
  cursor: pointer;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--accent-glow);
  transition: box-shadow 0.2s;
}
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 6px var(--accent-glow); }

.number-input {
  width: 110px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
}
.number-input:focus { border-color: var(--accent); }
.number-input::-webkit-inner-spin-button { opacity: 0.5; }

/* ─── Compress Button ─────────────────────────────────────────── */
.btn-compress {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, #5a3fff 100%);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 24px rgba(123,97,255,0.4);
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.btn-compress::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 60%);
}
.btn-compress:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 6px 32px rgba(123,97,255,0.55); }
.btn-compress:active:not(:disabled) { transform: translateY(0); }
.btn-compress:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn-compress-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Result card ─────────────────────────────────────────────── */
.result-card { animation: fadeSlideUp 0.4s ease; }
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.result-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.result-label--after { color: var(--accent-2); }

.result-img-wrap {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a0a10;
}
.result-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.result-stats { display: flex; flex-direction: column; gap: 6px; }
.stat { display: flex; justify-content: space-between; align-items: center; font-size: 0.82rem; }
.stat-label { color: var(--text-muted); }
.stat-value { font-weight: 500; color: var(--text); }
.stat-value.highlight { color: var(--accent-2); font-weight: 600; }
.stat-constraint-icon { font-size: 14px; vertical-align: middle; margin-right: 4px; }

.result-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
}
.result-arrow .ti { font-size: 28px; line-height: 1; }

.savings-badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  color: var(--accent-2);
  white-space: nowrap;
  text-align: center;
}

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-download {
  flex: 1;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent-2), #009e7f);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0,212,170,0.35);
  transition: opacity 0.2s, transform 0.15s;
}
.btn-download:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-download .ti { font-size: 18px; line-height: 1; }

.btn-again {
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-again:hover { color: var(--text); border-color: rgba(255,255,255,0.15); }

/* ─── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: toastIn 0.3s ease;
  max-width: 90vw;
}
.toast--error { background: #2a1018; border: 1px solid rgba(255,92,92,0.4); color: var(--red); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.toast-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.7;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
}
.toast-close:hover { opacity: 1; }

/* ─── Footer ──────────────────────────────────────────────────── */
.footer { text-align: center; font-size: 0.8rem; color: var(--text-dim); }
.footer code { color: var(--text-muted); background: var(--surface); padding: 2px 8px; border-radius: 6px; }
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ─── Utilities ───────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Tool Tabs ────────────────────────────────────────────────── */
.tool-tabs {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
}

.tool-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tool-tab .ti { font-size: 1.1rem; }
.tool-tab:hover { color: var(--text); background: var(--surface-2); }
.tool-tab.active {
  background: linear-gradient(135deg, var(--accent), #5a3fff);
  color: #fff;
  box-shadow: 0 4px 16px rgba(123,97,255,0.35);
}

/* ─── Tool Panels ──────────────────────────────────────────────── */
.tool-panel { display: flex; flex-direction: column; gap: 24px; }

/* ─── PDF Thumb in file preview ────────────────────────────────── */
.pdf-thumb {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pdf-thumb .ti { font-size: 2rem; color: #e25b5b; }

/* ─── PDF Info box ─────────────────────────────────────────────── */
.pdf-info-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(123,97,255,0.08);
  border: 1px solid rgba(123,97,255,0.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}
.pdf-info-box .ti { font-size: 1.1rem; color: var(--accent); flex-shrink: 0; margin-top: 1px; }

/* ─── PDF compress button variant ──────────────────────────────── */
.btn-compress--pdf {
  background: linear-gradient(135deg, #e25b5b 0%, #c0392b 100%);
  box-shadow: 0 4px 24px rgba(226,91,91,0.35);
}
.btn-compress--pdf:hover:not(:disabled) { box-shadow: 0 6px 32px rgba(226,91,91,0.5); }

/* ─── PDF Result ────────────────────────────────────────────────── */
.pdf-result-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.pdf-result-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.pdf-result-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  background: rgba(226,91,91,0.1);
  border: 1px solid rgba(226,91,91,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pdf-result-icon .ti { font-size: 2.2rem; color: #e25b5b; }
.pdf-result-icon--after { background: rgba(0,212,170,0.1); border-color: rgba(0,212,170,0.25); }
.pdf-result-icon--after .ti { color: var(--accent-2); }

.pdf-result-panel .result-stats { width: 100%; }

.result-arrow--pdf { flex-direction: column; }

/* ─── PDF download button ──────────────────────────────────────── */
.btn-download--pdf {
  background: linear-gradient(135deg, #e25b5b, #c0392b);
  box-shadow: 0 4px 20px rgba(226,91,91,0.3);
}
.btn-download--pdf:hover { box-shadow: 0 6px 28px rgba(226,91,91,0.45); }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 560px) {
  .result-grid { grid-template-columns: 1fr; }
  .pdf-result-grid { grid-template-columns: 1fr; }
  .result-arrow, .result-arrow--pdf { flex-direction: row; }
  .savings-badge { writing-mode: horizontal-tb; }
  .tool-tab span { display: none; }
  .tool-tab { padding: 12px; }
}

