:root {
  --bg: #0a0d12;
  --card: rgba(18, 22, 29, 0.86);
  --border: #232a36;
  --border-soft: #2b3547;
  --text: #e8ecf2;
  --muted: #8b95a7;
  --accent: #8b5cf6;
  --accent2: #22d3ee;
  --danger: #f87171;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 400px at 15% -10%, rgba(139, 92, 246, 0.16), transparent 70%),
    radial-gradient(700px 450px at 110% 15%, rgba(34, 211, 238, 0.10), transparent 70%),
    radial-gradient(500px 400px at 50% 120%, rgba(139, 92, 246, 0.08), transparent 70%);
}

main {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 20px 40px;
}

/* ---------- hero ---------- */

.hero { text-align: center; margin-bottom: 32px; }

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 6vw, 2.6rem);
  letter-spacing: -0.02em;
}

.grad {
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p { margin: 0; color: var(--muted); }

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.hidden { display: none !important; }

/* ---------- dropzone ---------- */

.dropzone {
  border: 2px dashed var(--border-soft);
  border-radius: 14px;
  padding: 42px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  outline: none;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.drag {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.07);
}

.dz-icon { color: var(--muted); margin-bottom: 10px; }
.dropzone:hover .dz-icon, .dropzone.drag .dz-icon { color: var(--accent2); }

.dz-main { font-size: 1.15rem; font-weight: 600; margin-bottom: 4px; }
.dz-sub { color: var(--muted); font-size: 0.9rem; }
.dz-sub .link { color: var(--accent2); }

/* ---------- file info ---------- */

.fileinfo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.fileinfo video {
  width: 128px;
  max-height: 84px;
  border-radius: 10px;
  background: #000;
  flex-shrink: 0;
}

.filetext { min-width: 0; flex: 1; }

.fname {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fmeta { color: var(--muted); font-size: 0.85rem; }

/* ---------- form ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .fileinfo video { display: none; }
}

.field { display: block; margin-bottom: 2px; }

.field > span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 7px;
}

.field output { color: var(--text); font-weight: 600; }
.field em { font-style: normal; font-size: 0.78rem; opacity: 0.8; }

.field input[type="number"],
.field input[type="password"] {
  width: 100%;
  background: #0e1218;
  border: 1px solid #26303f;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.field input[type="number"]:focus,
.field input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 10px 0 4px;
}

.quality { margin-top: 16px; }

.estimate {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 18px 0 14px;
}

/* ---------- buttons ---------- */

.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  cursor: pointer;
  text-decoration: none !important;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}

.primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35); }
.primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.ghost {
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}

.ghost:hover { color: var(--text); border-color: var(--accent); }
.ghost.small { padding: 7px 12px; font-size: 0.85rem; flex-shrink: 0; }

/* ---------- progress ---------- */

.phase { font-weight: 600; margin-bottom: 12px; }

.progress {
  height: 10px;
  background: #0e1218;
  border-radius: 999px;
  overflow: hidden;
}

#bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .3s ease;
}

.progress.indet #bar {
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent));
  background-size: 200% 100%;
  animation: slide 1.2s linear infinite;
}

@keyframes slide {
  from { background-position: 200% 0; }
  to   { background-position: 0 0; }
}

.progmeta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 9px;
  min-height: 1.2em;
}

.prognote { color: var(--muted); font-size: 0.85rem; margin: 12px 0 0; }

/* ---------- result ---------- */

.statrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  background: #0e1218;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.chip strong { color: var(--text); font-weight: 600; }

.gifwrap {
  border-radius: 12px;
  margin-bottom: 18px;
  text-align: center;
  background:
    repeating-conic-gradient(#141922 0% 25%, #0e1218 0% 50%) 0 0 / 24px 24px;
  border: 1px solid var(--border);
  overflow: hidden;
  min-height: 80px;
}

.gifwrap img { max-width: 100%; display: block; margin: 0 auto; }

.actions { display: flex; gap: 12px; }
.actions .primary { flex: 1; }
.actions .ghost { flex-shrink: 0; }

/* ---------- error ---------- */

.error { border-color: rgba(248, 113, 113, 0.35); background: rgba(127, 29, 29, 0.12); }
.err-title { color: var(--danger); font-weight: 700; margin-bottom: 6px; }
.error p { margin: 0 0 14px; color: var(--text); }

/* ---------- footer ---------- */

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 26px;
}

footer p { margin: 0; }

/* ---------- auth ---------- */

.login-main { max-width: 420px; padding-top: 12vh; }

.login-form .field { margin-bottom: 16px; }

.login-error { color: var(--danger); font-size: 0.9rem; margin: 0 0 14px; }

.logout {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 0.82rem;
  color: var(--muted);
}
.logout:hover { color: var(--text); text-decoration: none; }
