:root {
  --pink: #eb8be3;
  --pink-strong: #d95ece;
  --ink: #242121;
  --muted: #6d656d;
  --line: #ded8df;
  --line-strong: #c8bec8;
  --surface: #ffffff;
  --wash: #f8f5f9;
  --dark: #171515;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0 0, rgba(235, 139, 227, 0.22), transparent 34rem),
    linear-gradient(180deg, #fff 0%, var(--wash) 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 52px;
}

.brand,
.nav-link {
  color: inherit;
  font-weight: 800;
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.nav-link {
  border-bottom: 2px solid var(--pink);
}

.headline {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(280px, 0.55fr);
  gap: 34px;
  align-items: end;
  margin-bottom: 34px;
}

h1 {
  margin: 0;
  font-size: clamp(3.2rem, 9vw, 7.5rem);
  line-height: 0.86;
  letter-spacing: 0;
}

.headline p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.control-panel,
.preview-panel,
.output-card {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(45, 37, 50, 0.08);
}

.control-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.drop-zone {
  min-height: 190px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 22px;
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--pink-strong);
  background: #fff8fe;
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--pink);
  border-radius: 8px;
}

.drop-icon svg {
  width: 30px;
  height: 30px;
}

.drop-title {
  font-size: 1.18rem;
  font-weight: 850;
}

.drop-copy,
.file-list,
.output-card p {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.file-list {
  min-height: 21px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.preset-group {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preset-group legend {
  padding: 0 4px;
  color: #4d474d;
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.preset-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.preset-options label {
  min-height: 38px;
  display: grid;
  place-items: center;
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
  cursor: pointer;
}

.preset-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.preset-options label:has(input:checked) {
  border-color: var(--pink-strong);
  background: #fff1fd;
  box-shadow: inset 0 0 0 1px var(--pink-strong);
}

.preset-group p,
.estimate {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.range-field output {
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
  color: #4d474d;
}

.field input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 720;
}

.field input:focus-visible,
.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.download-btn:focus-visible,
.secondary-link:focus-visible,
.nav a:focus-visible {
  outline: 3px solid rgba(235, 139, 227, 0.42);
  outline-offset: 3px;
}

.range-field {
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 14px;
}

.range-field input {
  grid-column: 1 / -1;
  accent-color: var(--pink-strong);
}

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.primary-btn,
.secondary-btn,
.download-btn,
.secondary-link {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--dark);
  background: var(--pink);
  border: 0;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, opacity 160ms ease;
}

.secondary-btn {
  min-width: 96px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
}

.primary-btn svg,
.download-btn svg {
  width: 20px;
  height: 20px;
}

.primary-btn:hover,
.secondary-btn:hover,
.download-btn:hover,
.secondary-link:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.primary-btn:disabled,
.secondary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.status {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #ece6ed;
}

progress::-webkit-progress-bar {
  background: #ece6ed;
}

progress::-webkit-progress-value {
  background: var(--pink-strong);
}

progress::-moz-progress-bar {
  background: var(--pink-strong);
}

.preview-panel {
  padding: 18px;
}

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

.preview-header h2 {
  margin: 0 0 4px;
  font-size: 1.35rem;
  line-height: 1.1;
}

.preview-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.ready-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: #f1edf2;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.ready-pill[data-state="ready"] {
  color: #163c25;
  background: #dff4e6;
  border-color: #b7dfc4;
}

.ready-pill[data-state="working"] {
  color: #53320b;
  background: #fff0cc;
  border-color: #f0ce7c;
}

.ready-pill[data-state="error"] {
  color: #661d1d;
  background: #ffe0e0;
  border-color: #efb0b0;
}

.preview-frame {
  position: relative;
  min-height: 520px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(36, 33, 33, 0.045) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(36, 33, 33, 0.045) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(36, 33, 33, 0.045) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(36, 33, 33, 0.045) 75%),
    #fff;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

canvas {
  max-width: 100%;
  max-height: 500px;
  width: auto;
  height: auto;
  display: block;
  box-shadow: 0 22px 70px rgba(36, 33, 33, 0.18);
}

#videoSource {
  display: none;
}

.empty-state {
  position: absolute;
  inset: auto 24px 24px;
  padding: 12px 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 750;
  text-align: center;
}

.output-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
  margin-top: 18px;
  padding: 18px;
}

.output-card h2 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  line-height: 1.1;
}

.output-card p {
  margin: 0;
}

.output-preview-frame {
  width: min(100%, 420px);
  aspect-ratio: var(--gif-ratio, 16 / 9);
  min-height: 180px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.output-card img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  object-fit: contain;
}

.output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.download-btn,
.secondary-link {
  justify-self: start;
  padding: 0 18px;
}

.secondary-link {
  min-height: 44px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
}

@media (max-width: 900px) {
  .headline,
  .workspace {
    grid-template-columns: 1fr;
  }

  .workspace {
    gap: 16px;
  }

  .preview-frame {
    min-height: 360px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 28px, 1180px);
    padding: 24px 0 34px;
  }

  .nav {
    margin-bottom: 40px;
  }

  .field-grid,
  .action-row,
  .output-card {
    grid-template-columns: 1fr;
  }

  .output-preview-frame,
  .output-card img,
  .download-btn,
  .secondary-link {
    width: 100%;
    max-width: none;
  }

  .output-preview-frame {
    min-height: 240px;
  }

  .output-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
