:root {
  --bg-main: #f0f8f2;
  --bg-card: #ffffff;
  --bg-soft: #ebf7ee;
  --text-main: #153026;
  --text-muted: #4b6b5f;
  --green-900: #0d5f3f;
  --green-700: #178b5a;
  --green-500: #24b56f;
  --green-300: #76d8a6;
  --line: #d6eadd;
  --shadow: 0 18px 35px rgba(21, 94, 59, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Outfit", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 15% 20%, rgba(36, 181, 111, 0.22), transparent 38%),
    radial-gradient(circle at 92% 0%, rgba(13, 95, 63, 0.2), transparent 30%),
    var(--bg-main);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-ornament {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(30px);
  opacity: 0.45;
}

.bg-ornament-a {
  width: 280px;
  height: 280px;
  background: rgba(46, 193, 124, 0.5);
  top: -60px;
  right: -80px;
}

.bg-ornament-b {
  width: 240px;
  height: 240px;
  background: rgba(13, 95, 63, 0.45);
  bottom: 8%;
  left: -90px;
}

.container {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100vw - 32px));
  margin: 36px auto 56px;
}

.hero {
  text-align: center;
  margin-bottom: 28px;
  animation: rise-in 0.6s ease;
}

.tag {
  margin: 0;
  color: var(--green-900);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.76rem;
}

h1 {
  margin: 10px 0 10px;
  font-family: "Sora", sans-serif;
  font-size: clamp(1.7rem, 2.6vw, 2.7rem);
  line-height: 1.2;
}

.subtitle {
  margin: 0 auto;
  max-width: 720px;
  color: var(--text-muted);
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(255, 255, 255, 0.92));
  border: 1px solid rgba(13, 95, 63, 0.1);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
}

.upload-panel {
  padding: 24px;
  animation: rise-in 0.65s ease;
}

.drop-zone {
  border: 2px dashed var(--green-300);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(36, 181, 111, 0.08), rgba(13, 95, 63, 0.08)),
    var(--bg-soft);
  padding: 28px;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-active {
  border-color: var(--green-700);
  transform: translateY(-1px);
  background:
    linear-gradient(135deg, rgba(36, 181, 111, 0.16), rgba(13, 95, 63, 0.13)),
    #e3f3e8;
}

.drop-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  line-height: 1;
  color: #fff;
  background: linear-gradient(140deg, var(--green-700), var(--green-500));
  box-shadow: 0 10px 24px rgba(23, 139, 90, 0.35);
}

.drop-title {
  margin: 6px 0 4px;
  font-family: "Sora", sans-serif;
  font-weight: 600;
}

.drop-subtitle {
  margin: 0;
  color: var(--text-muted);
}

.controls-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

.control-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: var(--bg-card);
}

.control-label {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
}

.preset-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-main);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-btn:hover {
  border-color: var(--green-700);
  color: var(--green-900);
}

.preset-btn.active {
  border-color: transparent;
  background: linear-gradient(145deg, var(--green-700), var(--green-500));
  color: #fff;
}

.custom-range {
  margin-top: 12px;
}

.custom-range label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text-muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green-700);
}

.file-summary {
  display: grid;
  align-content: center;
}

.file-count {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 600;
}

.file-hint {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.action-row {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.16s ease, filter 0.16s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.btn-primary {
  background: linear-gradient(145deg, var(--green-900), var(--green-700));
  color: #fff;
}

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text-main);
}

.results-panel {
  margin-top: 20px;
  padding: 18px;
  animation: rise-in 0.5s ease;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.results-header h2 {
  margin: 0 0 3px;
  font-family: "Sora", sans-serif;
  font-size: 1.2rem;
}

.results-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 14px;
}

.result-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 12px;
}

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.result-name {
  margin: 0;
  font-size: 0.98rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  background: #e6f7ed;
  color: var(--green-900);
  border-radius: 999px;
  padding: 4px 8px;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

figure {
  margin: 0;
}

figcaption {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.preview-grid img {
  width: 100%;
  height: 130px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #f4f8f6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.stat-original,
.stat-compressed,
.stat-reduction {
  margin: 4px 0 0;
  font-size: 0.83rem;
  line-height: 1.3;
}

.stat-reduction {
  font-weight: 700;
  color: var(--green-900);
}

.btn-download {
  width: 100%;
}

.hidden {
  display: none;
}

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

@media (max-width: 840px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }

  #downloadAllBtn {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .container {
    width: calc(100vw - 18px);
    margin-top: 20px;
  }

  .upload-panel {
    padding: 14px;
  }

  .drop-zone {
    padding: 20px 14px;
  }

  .preview-grid img {
    height: 110px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .action-row .btn {
    width: 100%;
  }
}
