:root {
  color-scheme: dark;
  --bg: #09090b;
  --panel: rgba(22, 22, 26, .82);
  --panel-strong: rgba(27, 27, 32, .96);
  --surface: rgba(255, 255, 255, .045);
  --surface-hover: rgba(255, 255, 255, .075);
  --line: rgba(255, 255, 255, .095);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #fafafa;
  --muted: #a1a1aa;
  --faint: #71717a;
  --accent: #ff3b45;
  --accent-dark: #dc2626;
  --accent-soft: rgba(255, 59, 69, .14);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: "DM Sans", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(220, 38, 38, .18), transparent 31%),
    radial-gradient(circle at 90% 88%, rgba(91, 33, 182, .12), transparent 28%),
    linear-gradient(150deg, #08080a 0%, #101014 48%, #08080a 100%);
  color: var(--text);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .26;
  background-image: radial-gradient(rgba(255,255,255,.13) .55px, transparent .55px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.ambient { position: fixed; pointer-events: none; filter: blur(90px); border-radius: 50%; opacity: .18; }
.ambient-one { width: 420px; height: 420px; left: -180px; top: 8%; background: #ef4444; }
.ambient-two { width: 360px; height: 360px; right: -160px; bottom: 2%; background: #6d28d9; }

.page-shell { width: min(1040px, 100%); margin: 0 auto; padding: 52px 22px; }
.app-card {
  position: relative;
  overflow: hidden;
  padding: 38px;
  background: linear-gradient(145deg, rgba(29,29,34,.91), rgba(16,16,20,.86));
  border: 1px solid var(--line);
  border-radius: 32px;
  box-shadow: 0 34px 100px rgba(0,0,0,.52), inset 0 1px rgba(255,255,255,.045);
  backdrop-filter: blur(28px);
}
.app-card::before {
  content: "";
  position: absolute;
  height: 1px;
  left: 12%; right: 12%; top: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
}

.hero { margin-bottom: 30px; }
.brand-row { display: flex; align-items: center; gap: 15px; }
.logo {
  width: 58px; height: 58px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 18px;
  background: linear-gradient(145deg, #ff4d56, #cf151f);
  box-shadow: 0 14px 35px rgba(220,38,38,.34), inset 0 1px rgba(255,255,255,.3);
  transform: rotate(-3deg);
}
.logo svg { width: 27px; height: 27px; stroke-width: 2.4; }
.brand-copy { min-width: 0; }
.eyebrow { display: block; margin-bottom: 2px; color: #fca5a5; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(27px, 4vw, 36px); line-height: 1; letter-spacing: -.045em; }
.desktop-badge {
  margin-left: auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 12px; color: #d4d4d8; background: rgba(255,255,255,.045);
  border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 600;
}
.desktop-badge svg { width: 15px; color: #4ade80; }
.hero-copy { max-width: 650px; margin: 19px 0 0; color: var(--muted); font-size: 15px; line-height: 1.65; }

.form-stack { display: grid; gap: 16px; }
.control-card, .media-panel, .progress-panel {
  background: rgba(8,8,11,.38);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.control-card { padding: 19px; }
.url-card { padding: 21px; }
.settings-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 16px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-heading > div { display: flex; align-items: center; gap: 10px; }
.section-heading h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.section-heading.compact { margin-bottom: 13px; }
.step { color: #f87171; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.hint { color: var(--faint); font-size: 12px; }

.url-wrap { position: relative; }
.input-icon { position: absolute; z-index: 1; left: 16px; top: 50%; width: 19px; transform: translateY(-50%); color: #71717a; pointer-events: none; }
input, select {
  width: 100%; color: #fff; background: rgba(255,255,255,.055);
  border: 1px solid rgba(255,255,255,.11); outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input { height: 57px; padding: 0 48px 0 47px; border-radius: 15px; font-size: 15px; }
input::placeholder { color: #71717a; }
input:hover, select:hover { background: rgba(255,255,255,.07); border-color: var(--line-strong); }
input:focus, select:focus { border-color: rgba(255,59,69,.8); box-shadow: 0 0 0 4px var(--accent-soft); }
.spinner { position: absolute; right: 17px; top: 19px; width: 19px; height: 19px; border: 2px solid #52525b; border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-text { display: flex; min-height: 17px; align-items: center; margin: 9px 2px 0; color: var(--faint); font-size: 12px; }
.status-text.text-red-400 { color: #f87171; }

.format-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.format-btn {
  position: relative; min-width: 0; display: grid; grid-template-columns: 38px minmax(0,1fr) 18px;
  gap: 10px; align-items: center; padding: 11px; text-align: left; color: var(--muted);
  background: var(--surface); border: 1px solid transparent; border-radius: 14px;
  transition: transform .2s, border-color .2s, background .2s, box-shadow .2s;
}
.format-btn:hover { transform: translateY(-1px); background: var(--surface-hover); }
.format-btn .format-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.06); }
.format-btn svg { width: 18px; }
.format-btn b, .format-btn small { display: block; }
.format-btn b { color: #e4e4e7; font-size: 13px; }
.format-btn small { margin-top: 2px; color: var(--faint); font-size: 10px; white-space: nowrap; }
.format-btn .check-icon { opacity: 0; width: 16px; color: white; }
.format-btn.active { color: white; background: linear-gradient(145deg, rgba(255,59,69,.24), rgba(220,38,38,.11)); border-color: rgba(255,59,69,.46); box-shadow: inset 0 1px rgba(255,255,255,.04); }
.format-btn.active .format-icon { background: var(--accent); box-shadow: 0 7px 18px rgba(220,38,38,.28); }
.format-btn.active .check-icon { opacity: 1; }

.quality-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
label { display: block; margin-bottom: 7px; color: #a1a1aa; font-size: 11px; font-weight: 600; }
.select-wrap { position: relative; }
select { height: 46px; padding: 0 38px 0 13px; appearance: none; border-radius: 13px; font-size: 12px; }
select option { background: #18181b; }
.select-wrap svg { position: absolute; right: 12px; top: 50%; width: 16px; transform: translateY(-50%); color: #71717a; pointer-events: none; }

.media-panel, .progress-panel { padding: 18px; }
.panel-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 13px; }
.panel-title-wrap { display: flex; align-items: center; gap: 11px; min-width: 0; }
.panel-icon { width: 37px; height: 37px; flex: 0 0 auto; display: grid; place-items: center; color: #f87171; background: var(--accent-soft); border-radius: 11px; }
.panel-icon svg { width: 18px; }
.panel-head h2 { max-width: 540px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.panel-head p { display: flex; align-items: center; gap: 7px; margin: 3px 0 0; color: var(--faint); font-size: 11px; }
.dot { width: 3px; height: 3px; background: #52525b; border-radius: 50%; }
.selection-tools { display: flex; gap: 6px; }
.selection-tools button { padding: 7px 10px; color: #d4d4d8; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; font-size: 10px; transition: .2s; }
.selection-tools button:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.media-list { max-height: 350px; overflow: auto; display: grid; gap: 8px; padding-right: 4px; scrollbar-width: thin; scrollbar-color: #3f3f46 transparent; }
.media-item { display: grid; grid-template-columns: 19px 100px minmax(0,1fr) 34px; gap: 11px; align-items: center; margin: 0; padding: 9px; background: rgba(255,255,255,.032); border: 1px solid transparent; border-radius: 13px; transition: transform .2s, border-color .2s, background .2s, opacity .2s; }
.media-item:hover { transform: translateY(-1px); background: rgba(255,255,255,.052); border-color: rgba(255,59,69,.25); }
.media-item.disabled { opacity: .42; }
.media-item input { width: 16px; height: 16px; padding: 0; accent-color: var(--accent-dark); box-shadow: none; }
.thumb-wrap { position: relative; width: 100px; aspect-ratio: 16/9; overflow: hidden; border-radius: 9px; background: #27272a; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.thumb-wrap span { position: absolute; right: 4px; bottom: 4px; padding: 2px 5px; background: rgba(0,0,0,.82); border-radius: 5px; font-size: 9px; }
.thumb-placeholder { height: 100%; display: grid; place-items: center; color: #71717a; }
.media-copy { min-width: 0; }
.media-copy strong, .media-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-copy strong { font-size: 13px; }
.media-copy small { margin-top: 4px; color: var(--faint); font-size: 11px; }
.remove-btn { width: 32px; height: 32px; display: grid; place-items: center; color: #71717a; background: transparent; border: 0; border-radius: 9px; transition: .2s; }
.remove-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.remove-btn svg { width: 16px; }

.progress-panel { background: linear-gradient(145deg, rgba(255,59,69,.08), rgba(8,8,11,.42)); border-color: rgba(255,59,69,.19); }
.progress-head { display: flex; justify-content: space-between; gap: 15px; }
.progress-head span { display: block; color: var(--muted); font-size: 11px; }
.progress-head strong { display: block; max-width: 670px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.progress-percent { color: #fca5a5; font-size: 14px; }
.progress-track { height: 9px; margin-top: 14px; overflow: hidden; background: rgba(255,255,255,.08); border-radius: 999px; }
#progress-bar { position: relative; width: 0; height: 100%; background: linear-gradient(90deg, #dc2626, #fb7185); border-radius: inherit; transition: width .2s linear; }
#progress-bar::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); transform: translateX(-100%); animation: shimmer 1.7s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
#progress-detail { margin: 8px 0 0; color: var(--muted); font-size: 11px; }

.action-row { display: flex; gap: 10px; margin-top: 2px; }
.primary-btn, .cancel-btn { min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 15px; font-weight: 700; transition: transform .2s, box-shadow .2s, background .2s, opacity .2s; }
.primary-btn { position: relative; overflow: hidden; flex: 1; color: #fff; background: linear-gradient(135deg, #ff4650, #d71924); box-shadow: 0 14px 35px rgba(220,38,38,.24), inset 0 1px rgba(255,255,255,.28); }
.primary-btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(220,38,38,.36), inset 0 1px rgba(255,255,255,.32); }
.primary-btn:not(:disabled):active { transform: translateY(0); }
.primary-btn:disabled { opacity: .42; filter: saturate(.65); }
.primary-btn svg, .cancel-btn svg { width: 19px; position: relative; }
.primary-btn span, .cancel-btn { position: relative; }
.button-glow { position: absolute !important; width: 140px; height: 140px; left: 12%; top: -110px; background: rgba(255,255,255,.23); filter: blur(24px); border-radius: 50%; }
.cancel-btn { padding: 0 22px; color: #fff; background: rgba(255,255,255,.09); border: 1px solid var(--line); }
.cancel-btn:hover { background: rgba(255,255,255,.13); }
.legal-note { display: flex; justify-content: center; align-items: center; gap: 7px; margin: -1px 0 0; color: #52525b; font-size: 10px; }
.legal-note svg { width: 13px; }

.toast { position: fixed; right: 20px; top: 20px; max-width: min(420px, calc(100vw - 40px)); padding: 13px 16px; border: 1px solid; border-radius: 13px; box-shadow: 0 18px 50px rgba(0,0,0,.48); backdrop-filter: blur(18px); z-index: 20; font-size: 13px; animation: toastIn .25s ease both; }
.toast.success { background: rgba(5,46,22,.9); border-color: #16a34a; }
.toast.error { background: rgba(69,10,10,.92); border-color: #dc2626; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 820px) {
  .page-shell { padding: 30px 16px; }
  .app-card { padding: 28px; border-radius: 27px; }
  .settings-grid { grid-template-columns: 1fr; }
  .format-btn { padding: 12px; }
}

@media (max-width: 560px) {
  .page-shell { padding: 10px 8px calc(16px + env(safe-area-inset-bottom)); }
  .app-card { padding: 20px 12px 14px; border-radius: 24px; }
  .hero { margin: 4px 5px 23px; }
  .brand-row { gap: 12px; }
  .logo { width: 49px; height: 49px; border-radius: 15px; }
  .logo svg { width: 23px; }
  .eyebrow { font-size: 9px; }
  h1 { font-size: 27px; }
  .desktop-badge { display: none; }
  .hero-copy { margin-top: 15px; font-size: 13px; line-height: 1.55; }
  .form-stack { gap: 11px; }
  .control-card, .media-panel, .progress-panel { border-radius: 17px; }
  .control-card, .url-card { padding: 15px; }
  .section-heading { margin-bottom: 11px; }
  .hint { display: none; }
  input { height: 54px; font-size: 16px; }
  .format-grid { gap: 7px; }
  .format-btn { grid-template-columns: 34px minmax(0,1fr); padding: 9px; gap: 8px; }
  .format-btn .format-icon { width: 34px; height: 34px; }
  .format-btn .check-icon { display: none; }
  .format-btn b { font-size: 12px; }
  .format-btn small { font-size: 9px; }
  .quality-grid { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .selection-tools { width: 100%; }
  .selection-tools button { flex: 1; }
  .media-panel, .progress-panel { padding: 14px; }
  .media-item { grid-template-columns: 17px 79px minmax(0,1fr) 28px; gap: 8px; padding: 7px; }
  .thumb-wrap { width: 79px; }
  .media-copy strong { font-size: 12px; }
  .remove-btn { width: 28px; height: 28px; }
  .action-row { position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 5; flex-direction: column; padding-top: 3px; }
  .primary-btn, .cancel-btn { min-height: 55px; border-radius: 14px; }
  .cancel-btn { padding: 0 18px; }
  .legal-note { padding: 0 12px; text-align: center; line-height: 1.4; }
  .toast { right: 10px; top: 10px; max-width: calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
