:root {
  --bg: #0f1410;
  --panel: #1a231c;
  --ink: #f2f5f0;
  --muted: #9aa894;
  --accent: #d7ff3c;
  --accent-ink: #14200a;
  --danger: #ff6b6b;
  --ok: #7dffb2;
  --line: #2c382e;
  --radius: 14px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #243528 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1c2a40 0%, transparent 50%),
    var(--bg);
  overflow-x: clip;
}

.site-header,
main {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 3.5vw, 2.5rem);
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  padding-bottom: 0.5rem;
}
.site-header-main {
  min-width: 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.brand-mark {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.4rem;
  flex: 0 0 auto;
}
.tagline { margin: 0.2rem 0 0; color: var(--muted); }
.header-discord {
  flex: 0 0 auto;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem 0.9rem;
}
.header-discord:hover {
  border-color: var(--accent);
}

main {
  padding-top: 1rem;
  padding-bottom: 3rem;
}

.home-layout {
  display: grid;
  gap: 1.5rem;
  align-items: start;
}
.home-layout .upload-card,
.home-layout .recent-card {
  margin-top: 0;
}
@media (min-width: 900px) {
  .home-layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 2rem 2.5rem;
    align-items: stretch;
  }
  .home-layout .hero {
    padding-top: 0.35rem;
  }
  .home-layout .upload-card {
    height: 100%;
  }
  .home-layout .recent-card {
    grid-column: 1 / -1;
  }
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
}
.hero-lead {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 36rem;
  margin: 0;
  line-height: 1.45;
}
.hero-steps {
  list-style: none;
  padding: 0;
  margin: 1.1rem 0 0;
  display: grid;
  gap: 0.45rem;
  max-width: 22rem;
}
.hero-steps li {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.3;
}
.hero-step-num {
  flex: 0 0 1.4rem;
  color: var(--accent);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.hero-price {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.hero-price strong { color: var(--accent); }

.upload-card, .job, .recent-card {
  margin-top: 1.5rem;
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.recent-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}
.recent-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 0.65rem;
}
.recent-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #121914;
}
.recent-main {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
  flex: 1 1 220px;
}
.recent-link {
  color: inherit;
  text-decoration: none;
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}
.recent-link:hover .recent-name { color: var(--accent); }
.recent-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  font-size: 0.8rem;
}
.recent-when {
  color: var(--muted);
}
.recent-ttl {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.recent-ttl.soon {
  color: #ffb36b;
}
.recent-badge {
  display: inline-flex;
  width: fit-content;
  color: var(--muted);
  font-size: 0.82rem;
}
.recent-item.status-completed .recent-badge { color: var(--ok); }
.recent-item.status-failed .recent-badge { color: var(--danger); }
.recent-item.status-cancelled .recent-badge { color: var(--muted); }
.recent-item.status-awaiting_review .recent-badge,
.recent-item.status-awaiting_crops .recent-badge,
.recent-item.status-awaiting_payment .recent-badge {
  color: var(--accent);
}
.recent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
button.tight, .button.tight {
  margin-top: 0;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
}

label { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; min-width: 0; }
input[type="number"], input[type="file"], input[type="text"], input[type="search"], select {
  width: 100%;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #101611;
  color: var(--ink);
  padding: 0.7rem 0.8rem;
}
input[type="file"] {
  padding: 0.55rem;
}
.grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin: 1rem 0;
}
.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.55rem 0;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  flex-shrink: 0;
  border: 1.5px solid color-mix(in srgb, var(--line) 70%, var(--muted));
  border-radius: 6px;
  background: #0b100d;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.check input[type="checkbox"]::after {
  content: "";
  width: 0.28rem;
  height: 0.52rem;
  border: solid transparent;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-0.5px, -1px);
}
.check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.check input[type="checkbox"]:checked::after {
  border-color: var(--accent-ink);
}
.check input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.check input[type="checkbox"]:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

button, .button {
  display: inline-block;
  margin-top: 1rem;
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.2rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
button.ghost, .button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.row { display: flex; justify-content: space-between; margin-bottom: 0.5rem; align-items: center; }
.stage-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-transform: capitalize;
}
.spinner {
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.bar {
  height: 10px;
  background: #101611;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
  position: relative;
}
.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #b6e84a, var(--accent));
  transition: width 0.4s ease;
}
.bar-active::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 30%,
    color-mix(in srgb, white 28%, transparent) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  animation: sheen 1.4s ease-in-out infinite;
  pointer-events: none;
}
.working {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  min-height: 1.4em;
}
.dots::after {
  content: "";
  animation: dots 1.4s steps(4, end) infinite;
}
.is-active .stage-label strong,
.is-active .stage-label {
  color: var(--ink);
}
.error { color: var(--danger); }
.ok { color: var(--ok); }

@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes sheen {
  0% { background-position: 120% 0; }
  100% { background-position: -80% 0; }
}
@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
  100% { content: ""; }
}
.reveals { list-style: none; padding: 0; margin: 1rem 0 0; }
.reveals li {
  display: grid;
  grid-template-columns: 4rem 1fr auto auto;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.reveals .t { color: var(--muted); }
.reveals .price { color: var(--accent); font-weight: 700; }
.reveals .skip { color: var(--muted); grid-column: 2 / -1; }
.meta { color: var(--muted); font-size: 0.85rem; }

.review-form { margin-top: 1.25rem; }
.review-form h2 { margin: 0 0 0.35rem; font-size: 1.2rem; }
.review-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.85rem; }
.review-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #121914;
}
.review-thumbs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.review-card .crop {
  width: 120px;
  height: 168px;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  background: #0b100d;
  border: 1px solid var(--line);
}
.match-picker {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.match-picker legend {
  padding: 0;
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.5rem;
}
.match-option {
  margin: 0;
  cursor: pointer;
}
.match-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.match-option-body {
  display: grid;
  gap: 0.3rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b100d;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.match-option input:checked + .match-option-body {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.match-option input:focus-visible + .match-option-body {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.match-option .match {
  width: 100%;
  aspect-ratio: 63 / 88;
  height: auto;
  object-fit: cover;
  border-radius: 6px;
  background: #070b08;
  border: 0;
  display: block;
}
.match-missing {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
}
.match-option-meta {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}
.match-name {
  font-size: 0.72rem;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.match-score {
  color: var(--muted);
  font-size: 0.68rem;
}
.card-lookup {
  display: grid;
  gap: 0.45rem;
}
.card-lookup > [data-lookup-toggle] {
  justify-self: start;
  margin-top: 0;
}
.card-lookup-panel {
  display: grid;
  gap: 0.45rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b100d;
}
.card-lookup-panel[hidden] {
  display: none;
}
.card-lookup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.card-lookup-row input[type="search"] {
  flex: 1 1 10rem;
  min-width: 0;
  margin: 0;
}
.card-lookup-row button {
  margin-top: 0;
}
.lookup-indicator {
  margin: 0;
}
.lookup-status {
  margin: 0;
}
.lookup-grid {
  margin-top: 0.15rem;
}
.review-fields { display: grid; gap: 0.55rem; }
.review-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.check.tight { margin: 0; }
.crop-select-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
}
.crop-select-bar button { margin-top: 0; }
.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.review-actions button { margin-top: 0; }
.inline-cancel { margin-top: 0.75rem; }
.inline-cancel button { margin-top: 0; }

.overlay-editor {
  margin: 1.25rem 0 1rem;
}
.overlay-editor h3 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.overlay-stage {
  position: relative;
  margin-top: 0.75rem;
  width: min(100%, 320px);
  max-height: min(70vh, 560px);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #070b08;
  user-select: none;
  touch-action: none;
}
.overlay-video,
.export-video {
  display: block;
  width: 100%;
  max-height: min(70vh, 560px);
  height: auto;
  vertical-align: top;
  background: #070b08;
}
.export-video {
  margin: 0.85rem 0 1rem;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--line);
}
.overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.overlay-guide {
  position: absolute;
  background: #3b82f6;
  box-shadow: 0 0 0 0.5px rgba(59, 130, 246, 0.35);
  pointer-events: none;
  z-index: 1;
}
.overlay-guide[hidden] { display: none; }
.overlay-guide-x {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
}
.overlay-guide-y {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
}
.overlay-label {
  position: absolute;
  transform: translate(-50%, -50%);
  margin: 0;
  border: 0;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font: 700 0.72rem/1.2 "Avenir Next", "Segoe UI", sans-serif;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  z-index: 2;
}
.overlay-label:active { cursor: grabbing; }
.overlay-label-price { color: #fff; }
.overlay-label-total {
  color: #fff;
  font-size: 0.8rem;
}

@media (max-width: 720px) {
  .review-card {
    grid-template-columns: 1fr;
    justify-items: start;
  }
  .review-thumbs {
    flex-direction: row;
    align-items: flex-start;
  }
  .reveals li {
    grid-template-columns: 3.5rem minmax(0, 1fr);
  }
  .reveals .name,
  .reveals .price,
  .reveals .score,
  .reveals .skip {
    grid-column: 2;
  }
  .reveals .t {
    grid-row: 1 / span 3;
    align-self: start;
  }
  .review-actions,
  .recent-actions,
  .crop-select-bar {
    width: 100%;
  }
  .review-actions button,
  .review-actions .button,
  .recent-actions .button,
  .crop-select-bar button {
    flex: 1 1 auto;
    text-align: center;
  }
}

@media (max-width: 560px) {
  .site-header { padding-top: 1.1rem; }
  .brand { font-size: 1.2rem; }
  .hero h1 { font-size: clamp(1.55rem, 7vw, 2rem); }
  .hero-lead { font-size: 1rem; }
  .upload-card, .job, .recent-card {
    margin-top: 1.1rem;
    padding: 1rem;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .row {
    gap: 0.5rem;
    align-items: flex-start;
  }
  .review-card .crop { width: 96px; height: 134px; }
  .match-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
  .overlay-stage { width: min(100%, 220px); }
  button, .button {
    width: 100%;
    text-align: center;
  }
  .review-actions button,
  .review-actions .button,
  .recent-actions .button,
  .crop-select-bar button {
    width: auto;
  }
  .inline-cancel button { width: 100%; }
}
