:root {
  --bg: #0a0c10;
  --panel: #12151c;
  --panel-2: #171b24;
  --border: #262b36;
  --text: #eef0f3;
  --text-dim: #8b93a3;
  --accent: #ff9d4d;
  --accent-2: #ff5c7c;
  --good: #2fbf71;
  --font-display: "Manrope", -apple-system, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding-bottom: 30px;
  animation: page-in 0.5s var(--ease);
}

@keyframes page-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

header {
  padding: 28px 20px 10px;
  text-align: center;
  background: radial-gradient(ellipse 700px 220px at 50% 0%, rgba(255, 157, 77, 0.14), transparent);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 40% 60% 60% 40% / 50% 50% 50% 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  animation: squish-pulse 2.2s var(--ease) infinite;
  flex-shrink: 0;
}

@keyframes squish-pulse {
  0%,
  100% {
    transform: scale(1, 1);
    border-radius: 40% 60% 60% 40% / 50% 50% 50% 50%;
  }
  50% {
    transform: scale(1.25, 0.8);
    border-radius: 60% 40% 40% 60% / 60% 60% 40% 40%;
  }
}

header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.02em; /* texto grande: tracking negativo, se lee mas junto de lo natural si no */
}

.brand-accent {
  color: var(--accent);
}

.subtitle {
  margin: 8px auto 0;
  color: var(--text-dim);
  font-size: 14px;
  max-width: 480px;
}

#dropzone {
  width: min(700px, calc(100vw - 40px));
  margin: 22px auto 0;
  padding: 46px 20px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), transform 0.15s var(--ease);
}

#dropzone:hover,
#dropzone:focus-visible {
  border-color: var(--accent);
  outline: none;
}

#dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(255, 157, 77, 0.08);
  transform: scale(1.01);
}

#dropzone-text {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
}

#global-controls {
  width: min(700px, calc(100vw - 40px));
  margin: 16px auto 0;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  animation: fade-up 0.4s var(--ease);
}

#global-controls[hidden] {
  display: none;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-dim);
}

.control-group select,
.control-group input {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  transition: border-color 0.2s var(--ease);
}

.control-group select:focus,
.control-group input:focus {
  outline: none;
  border-color: var(--accent);
}

#global-max-width {
  width: 110px;
}

#quality-value {
  font-family: var(--font-mono);
  color: var(--text);
}

button {
  font-family: var(--font-body);
  transition: transform 0.15s var(--ease), background-color 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

button:active {
  transform: scale(0.96);
}

#clear-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 7px;
  padding: 7px 14px;
  cursor: pointer;
  margin-left: auto;
}

#clear-btn:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

main {
  width: min(900px, calc(100vw - 40px));
  margin: 16px auto 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  animation: card-in 0.35s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-preview {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  background: var(--bg);
}

.card-body {
  padding: 12px 14px;
}

.card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.card-sizes {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* The before -> after size line is the tool's actual payoff, so it earns the
   one moment of emphasis on this page (see /focused-product-design) instead
   of just replacing "Convirtiendo..." instantly. Both are plain CSS
   @keyframes, which re-trigger automatically on insertion via innerHTML - no
   JS needed - and the existing prefers-reduced-motion rule below already
   neutralizes them. */
.result-reveal {
  animation: result-in 0.35s var(--ease) both;
}

@keyframes result-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.savings {
  font-weight: 600;
  display: inline-block;
  animation: savings-pop 0.4s var(--ease) both;
  animation-delay: 0.12s;
}

@keyframes savings-pop {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  60% {
    opacity: 1;
    transform: scale(1.08);
  }
  to {
    transform: scale(1);
  }
}

.savings.positive {
  color: var(--good);
}

.savings.negative {
  color: var(--accent-2);
}

.card-status {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.download-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a0d05;
  border: none;
  border-radius: 8px;
  padding: 8px 0;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-size: 13px;
}

.download-btn:hover {
  box-shadow: 0 6px 20px rgba(255, 157, 77, 0.3);
}

.remove-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  margin-top: 8px;
}

.remove-btn:hover {
  color: var(--accent-2);
}

footer {
  padding: 20px 20px 0;
  font-size: 11px;
  letter-spacing: 0.01em; /* texto chico: tracking positivo para legibilidad */
  color: var(--text-dim);
  text-align: center;
  max-width: 500px;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
