:root {
  /* Centralized design tokens keep the page easy to retheme without hunting
     through every selector. */
  --bg: #f2eee6;
  --panel: rgba(255, 252, 246, 0.88);
  --text: #1c1a18;
  --muted: #625a52;
  --accent: #4f8a5b;
  --accent-dark: #2f6140;
  --line: rgba(28, 26, 24, 0.12);
  --shadow: 0 28px 60px rgba(73, 55, 38, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  /* The layered gradients give the page some depth without relying on images. */
  background:
    radial-gradient(circle at top left, rgba(79, 138, 91, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(126, 165, 122, 0.15), transparent 24%),
    linear-gradient(135deg, #efe7da 0%, #f8f5ef 52%, #e6dfd3 100%);
}

.shell {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.panel {
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 2.6rem;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 16ch;
  font-size: clamp(2.4rem, 3.2vw, 4.15rem);
  line-height: 0.92;
}

.lead {
  max-width: 58ch;
  margin: 1.25rem 0 0;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--muted);
}

.lead-note {
  margin-top: 0.8rem;
  font-size: 0.96rem;
}

.form-panel {
  padding: 2rem;
}

.grid {
  /* Responsive form layout: fields wrap automatically as space gets tighter. */
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.field-upload {
  grid-area: upload;
}

.field-strategy {
  grid-area: strategy;
}

.field-weighted {
  grid-area: weighted;
}

.field-download {
  grid-area: download;
}

.field {
  display: grid;
  gap: 0.55rem;
  grid-template-rows: auto minmax(64px, auto) auto;
  align-content: start;
  padding: 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(28, 26, 24, 0.08);
}

.field.is-hidden {
  /* Hide the weighted field visually without collapsing its grid position. */
  visibility: hidden;
}

.field.is-hidden input,
.field.is-hidden select {
  pointer-events: none;
}

.field span {
  font-weight: 700;
  text-align: center;
}

.field small {
  color: var(--muted);
  line-height: 1.4;
}

input,
select,
button {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(28, 26, 24, 0.12);
  font: inherit;
}

input,
select {
  min-height: 64px;
  padding: 0.95rem 1rem;
  background: #fffdf9;
}

.field select {
  font-size: clamp(0.9rem, 1.5vw, 1.05rem);
  line-height: 1.3;
  padding-right: 2.4rem;
}

.strategy-select {
  font-size: 0.76rem;
  letter-spacing: -0.01em;
}

.field-strategy select,
.field-weighted input,
.field-download select {
  width: 100%;
  min-height: 64px;
  align-self: start;
}

.field-weighted input {
  text-align: center;
}

input[type="file"] {
  padding: 0.65rem;
}

.upload-zone {
  display: grid;
  gap: 0.25rem;
  min-height: 120px;
  padding: 1rem;
  border: 1px dashed rgba(28, 26, 24, 0.2);
  border-radius: 18px;
  background: #fffdf9;
  align-content: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.upload-zone strong {
  font-size: 1rem;
}

.upload-zone span {
  font-weight: 400;
  color: var(--muted);
}

.upload-zone.dragover,
.upload-zone:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff6ef;
  transform: translateY(-1px);
}

.upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.upload-list.is-clearing {
  pointer-events: none;
}

.upload-placeholder {
  color: var(--muted);
}

.upload-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(79, 138, 91, 0.1);
  color: var(--accent-dark);
  font-size: 0.92rem;
  word-break: break-word;
  transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
}

.upload-chip.is-removing {
  /* Short exit animation after a successful download clears the staged files. */
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  filter: blur(1px);
}

button {
  margin-top: 1.4rem;
  min-height: 54px;
  border: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #79a96f 100%);
  color: white;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 16px 24px rgba(79, 138, 91, 0.25);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 30px rgba(79, 138, 91, 0.28);
}

.alerts {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.alert {
  padding: 0.95rem 1rem;
  border-radius: 16px;
  font-weight: 500;
}

.alert.error {
  background: rgba(164, 31, 53, 0.09);
  color: #7f1930;
  border: 1px solid rgba(164, 31, 53, 0.15);
}

code {
  font-family: "SFMono-Regular", Consolas, monospace;
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(3, minmax(240px, 1fr));
    grid-template-areas:
      ". upload ."
      "strategy weighted download";
    align-items: start;
  }

  .field {
    min-height: 100%;
  }

  .field-download {
    align-self: end;
  }
}

@media (max-width: 640px) {
  /* Tighten spacing on small screens instead of shrinking text aggressively. */
  .shell {
    width: min(100% - 1rem, 980px);
    padding-top: 1rem;
  }

  .hero,
  .form-panel {
    padding: 1.25rem;
  }
}
