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

:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface2: #1a1a1a;
  --border: #2a2a2a;
  --accent: #e8ff47;
  --accent2: #ff6b35;
  --text: #f0f0f0;
  --muted: #666;
  --danger: #ff4444;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* NOISE OVERLAY */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1000;
  opacity: 0.4;
}

/* ─── HEADER ─────────────────────────────────── */
header {
  padding: 2rem 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10,10,10,0.95);
  backdrop-filter: blur(10px);
  z-index: 100;
}

.logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  line-height: 1;
}
.logo span { color: var(--accent2); }

.badge {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.3rem 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ─── HERO ───────────────────────────────────── */
.hero {
  padding: 5rem 3rem 3rem;
  max-width: 900px;
  margin: 0 auto;
}

.hero-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(3.5rem, 8vw, 7rem);
  line-height: 0.9;
  letter-spacing: 0.02em;
  margin-bottom: 1.5rem;
}
.hero-title .line2 {
  color: var(--accent);
  display: block;
  -webkit-text-stroke: 2px var(--accent);
}

.hero-sub {
  font-size: 0.95rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.05em;
}

/* ─── MAIN ───────────────────────────────────── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 3rem 6rem;
}

/* ─── SECTION LABEL ──────────────────────────── */
.section-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── DROP ZONE ──────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  background: var(--surface);
  padding: 4rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.drop-zone::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(232,255,71,0.03));
  pointer-events: none;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(232,255,71,0.04);
}
.drop-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}
.drop-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.8rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}
.drop-sub {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.1em;
}
#fileInput { display: none; }

/* ─── PREVIEW ────────────────────────────────── */
.preview-section { display: none; }
.preview-section.visible { display: block; }

.video-container {
  background: #000;
  border: 1px solid var(--border);
  overflow: hidden;
}
video {
  width: 100%;
  display: block;
  max-height: 400px;
  object-fit: contain;
}

.video-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  padding: 1rem 1.5rem;
  display: flex;
  gap: 2rem;
}
.info-chip {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.info-chip strong {
  color: var(--text);
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}

/* ─── CONTROLS ───────────────────────────────── */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.control-block {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.5rem;
}
.control-block label {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.value-display {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  color: var(--accent);
  min-width: 3.5rem;
  letter-spacing: 0.05em;
}

.unit-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  color: var(--muted);
}

.qual-hint {
  margin-top: 0.75rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  color: var(--muted);
}

input[type="range"] {
  -webkit-appearance: none;
  flex: 1;
  height: 2px;
  background: var(--border);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.trim-inputs {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.trim-field { flex: 1; }
.trim-field span {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.1em;
}
.trim-field input[type="number"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 1.1rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}
.trim-field input[type="number"]:focus {
  border-color: var(--accent);
}
.trim-sep {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  color: var(--muted);
  margin-top: 1.2rem;
}

/* ─── ERROR ──────────────────────────────────── */
.error-msg {
  background: rgba(255,68,68,0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  padding: 1rem 1.5rem;
  margin-top: 1rem;
  display: none;
  letter-spacing: 0.05em;
}
.error-msg.visible { display: block; }

/* ─── CONVERT BUTTON ─────────────────────────── */
.convert-section { display: none; }
.convert-section.visible { display: block; }

.btn-convert {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  padding: 1.4rem 2rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.btn-convert:hover { background: #fff; }
.btn-convert:active { transform: scale(0.99); }
.btn-convert:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

/* ─── PROGRESS ───────────────────────────────── */
.progress-section { display: none; }
.progress-section.visible { display: block; }

.progress-bar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  height: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}
.progress-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.75rem;
  letter-spacing: 0.08em;
}

/* ─── RESULT ─────────────────────────────────── */
.result-section { display: none; }
.result-section.visible { display: block; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--accent);
  padding: 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.result-gif-preview {
  width: 200px;
  height: 140px;
  object-fit: contain;
  border: 1px solid var(--border);
  background: #000;
  flex-shrink: 0;
}
.result-info { flex: 1; }
.result-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
  color: var(--accent);
}
.result-meta {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  line-height: 1.8;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-download:hover { background: var(--accent); color: #000; }

.btn-reset {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  margin-left: 0.75rem;
  transition: all 0.15s;
}
.btn-reset:hover { border-color: var(--muted); color: var(--text); }

/* ─── FOOTER ─────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
footer p {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.1em;
}
.ffmpeg-note {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.ffmpeg-note span { color: var(--accent); }

/* ─── FFMPEG LOADING SCREEN ──────────────────── */
.ffmpeg-loading {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.97);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}
.ffmpeg-loading.hidden { display: none; }

.loading-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  letter-spacing: 0.2em;
  color: var(--accent);
}
.loading-sub {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-align: center;
  max-width: 400px;
  line-height: 1.8;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── RESPONSIVE ─────────────────────────────── */
@media (max-width: 640px) {
  header { padding: 1.5rem; }
  .hero { padding: 3rem 1.5rem 2rem; }
  main { padding: 1.5rem 1.5rem 4rem; }
  .controls-grid { grid-template-columns: 1fr; }
  .result-card { flex-direction: column; }
  .result-gif-preview { width: 100%; height: 200px; }
  footer { padding: 1.5rem; flex-direction: column; gap: 0.75rem; text-align: center; }
}
