:root {
  --bg: #f4f7fb;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --border: #e4e9f1;
  --border-strong: #d8e0eb;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-soft-2: #dbeafe;
  --success: #059669;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning-bg: #fffbeb;
  --warning-text: #92400e;
  --radius-lg: 22px;
  --radius-md: 15px;
  --radius-sm: 11px;
  --shadow-card: 0 18px 55px rgba(15, 23, 42, 0.07), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-button: 0 10px 24px rgba(37, 99, 235, 0.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

.page-glow {
  position: fixed;
  width: 460px;
  height: 460px;
  border-radius: 999px;
  filter: blur(90px);
  opacity: 0.26;
  pointer-events: none;
  z-index: -1;
}
.page-glow-one { top: -180px; left: -170px; background: #bfdbfe; }
.page-glow-two { right: -180px; top: 210px; background: #e0e7ff; }

.app {
  width: min(940px, calc(100% - 32px));
  margin: 0 auto;
  padding: 52px 0 64px;
}

.app-header {
  text-align: center;
  margin: 0 auto 34px;
  max-width: 720px;
}
.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 17px;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
}
.brand-mark svg { width: 29px; height: 29px; }
.eyebrow,
.section-kicker {
  color: var(--accent);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.13em;
}
.app-header h1 {
  margin: 8px 0 8px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.035em;
  font-weight: 800;
}
.tagline {
  margin: 0;
  color: #334155;
  font-size: 16px;
  font-weight: 600;
}
.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.app-main { display: flex; flex-direction: column; gap: 18px; }
.card {
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 26px;
  backdrop-filter: blur(14px);
}
.hidden { display: none !important; }
.section-title {
  margin: 5px 0 18px;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.media-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-soft-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.dropzone {
  position: relative;
  border: 1.5px dashed #cbd5e1;
  border-radius: 18px;
  padding: 52px 22px;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.88), rgba(255, 255, 255, 0.94));
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}
.dropzone-content { display: flex; flex-direction: column; align-items: center; }
.upload-icon-wrap {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  border-radius: 22px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-2);
}
.upload-icon { width: 34px; height: 34px; }
.dropzone-title { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.dropzone-or { margin: 5px 0 15px; color: var(--muted); font-size: 13px; }
.dropzone-hint { margin: 15px 0 0; color: var(--muted-2); font-size: 11.5px; }

.btn {
  appearance: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 750;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary {
  min-height: 49px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-button);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .48; cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: #94a3b8; box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07); }
.btn-block { width: 100%; display: block; }

.preview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(245px, .75fr);
  gap: 22px;
  align-items: stretch;
}
.media-wrap {
  min-width: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.video-wrap { background: #020617; display: flex; align-items: center; justify-content: center; }
.video-wrap video { width: 100%; max-height: 440px; display: block; }
.audio-wrap {
  min-height: 260px;
  padding: 28px;
  background: linear-gradient(145deg, #0f172a, #1e293b);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.audio-art {
  width: 94px;
  height: 94px;
  border-radius: 30px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.12);
}
.audio-art svg { width: 48px; height: 48px; }
.audio-wrap audio { width: 100%; max-width: 420px; }
.metadata {
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 5px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.meta-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 49px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.meta-row:last-child { border-bottom: 0; }
.meta-label { color: var(--muted); }
.meta-value { font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.warning {
  margin: 16px 0 0;
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13px;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.audio-mode .options-grid { grid-template-columns: 1fr; }
.option-panel {
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #f8fafc;
}
.option-label { display: block; margin-bottom: 11px; font-size: 12.5px; font-weight: 800; color: #334155; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 9px; }
.preset-btn {
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: .15s ease;
}
.preset-btn:hover { border-color: var(--accent); color: var(--accent); }
.preset-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,.18); }
.select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #fff;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
}
.select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.radio-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.radio-option { position: relative; cursor: pointer; }
.radio-option input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card-text {
  min-height: 72px;
  padding: 12px 8px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: .15s ease;
}
.radio-card-text strong { font-size: 13px; }
.radio-card-text small { margin-top: 2px; font-size: 10.5px; color: var(--muted); }
.radio-option input:checked + .radio-card-text { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); background: var(--accent-soft); }
.privacy-note { margin: 12px 0 0; text-align: center; font-size: 11.5px; color: var(--muted); }

.progress-status { margin: 0 0 13px; font-size: 13.5px; color: var(--muted); }
.progress-bar-track { width: 100%; height: 9px; background: #e8edf4; border-radius: 999px; overflow: hidden; }
.progress-bar-fill { height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, #2563eb, #4f46e5); transition: width .2s ease; }
.progress-percent { margin: 8px 0 0; font-size: 12px; font-weight: 800; color: var(--muted); text-align: right; }

.results-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.results-header .section-title { margin-bottom: 0; }
.results-count { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.clip-card { overflow: hidden; background: #fff; border: 1px solid var(--border); border-radius: 15px; box-shadow: 0 8px 22px rgba(15,23,42,.05); }
.clip-video { width: 100%; display: block; background: #020617; aspect-ratio: 16 / 9; object-fit: contain; }
.clip-audio-shell { min-height: 132px; padding: 18px; background: linear-gradient(145deg, #0f172a, #1e293b); display: flex; align-items: center; justify-content: center; }
.clip-audio { width: 100%; }
.clip-info { padding: 14px; }
.clip-title { font-weight: 800; font-size: 14px; margin: 0 0 6px; }
.clip-meta { font-size: 12px; color: var(--muted); margin: 0 0 3px; }
.clip-download { display: block; width: 100%; margin-top: 12px; text-align: center; padding: 9px 0; background: var(--accent); color: #fff; border-radius: 9px; font-size: 12.5px; font-weight: 800; text-decoration: none; }
.clip-download:hover { background: var(--accent-hover); }

.error-box { background: var(--danger-bg); border: 1px solid #fecaca; color: var(--danger); border-radius: 13px; padding: 13px 16px; font-size: 13.5px; }
.app-footer { margin-top: 30px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--muted); font-size: 11.5px; }
.app-footer p { margin: 0; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(5,150,105,.09); }

@media (max-width: 760px) {
  .app { width: min(100% - 24px, 940px); padding-top: 30px; }
  .card { padding: 19px; border-radius: 18px; }
  .preview-layout, .options-grid { grid-template-columns: 1fr; }
  .audio-wrap { min-height: 220px; }
  .results-grid { grid-template-columns: 1fr; }
  .dropzone { padding: 38px 15px; }
  .dropzone-hint { max-width: 300px; }
}

@media (max-width: 460px) {
  .app { width: min(100% - 18px, 940px); }
  .app-header { margin-bottom: 24px; }
  .brand-mark { width: 48px; height: 48px; border-radius: 15px; }
  .app-header h1 { font-size: 30px; }
  .tagline { font-size: 14px; }
  .section-title { font-size: 18px; }
  .presets { grid-template-columns: repeat(4, 1fr); }
  .radio-group { grid-template-columns: 1fr; }
  .radio-card-text { min-height: 52px; flex-direction: row; gap: 7px; }
  .radio-card-text small { margin-top: 0; }
  .meta-row { grid-template-columns: 78px minmax(0, 1fr); }
  .results-header { flex-direction: column; }
}

/* PWA app icon + responsive refinements */
.brand-mark {
  width: 72px;
  height: 72px;
  padding: 0;
  overflow: hidden;
  border-radius: 22px;
  background: transparent;
  color: inherit;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.18);
}
.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.app {
  padding-top: calc(52px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

button,
select,
input,
a {
  -webkit-tap-highlight-color: transparent;
}

.video-wrap video,
.audio-wrap audio,
.clip-video,
.clip-audio {
  max-width: 100%;
}

@media (max-width: 760px) {
  .app {
    width: min(calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)), 940px);
    padding-top: calc(30px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(42px + env(safe-area-inset-bottom, 0px));
  }

  .app-main,
  .card,
  .preview-layout,
  .options-grid,
  .option-panel,
  .metadata {
    min-width: 0;
  }

  .btn,
  .preset-btn,
  .select {
    min-height: 44px;
  }

  .dropzone {
    min-height: 260px;
    display: grid;
    place-items: center;
  }

  .video-wrap video {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
  }
}

@media (max-width: 460px) {
  .brand-mark {
    width: 62px;
    height: 62px;
    border-radius: 19px;
  }

  .card {
    padding: 16px;
  }

  .dropzone {
    padding: 30px 12px;
  }

  .metadata {
    padding-left: 12px;
    padding-right: 12px;
  }

  .meta-row {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px;
  }
}

@media (max-width: 360px) {
  .app {
    width: min(calc(100% - 12px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)), 940px);
  }

  .presets {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-heading-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
