/* ===== RESET & TOKENS ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #09090b;
  --surface: #18181b;
  --surface-2: #27272a;
  --surface-3: #3f3f46;
  --border: #3f3f46;
  --text: #fafafa;
  --text-2: #d4d4d8;
  --text-muted: #71717a;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-light: rgba(124,58,237,0.18);
  --gradient: linear-gradient(135deg, #7c3aed 0%, #a855f7 55%, #ec4899 100%);
  --success: #10b981;
  --success-bg: rgba(16,185,129,0.12);
  --error: #ef4444;
  --error-bg: rgba(239,68,68,0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.3);
  --t: 0.18s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono','Fira Code','Cascadia Code',monospace;
}

[data-theme="light"] {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e4e4e7;
  --border: #d4d4d8;
  --text: #09090b;
  --text-2: #27272a;
  --text-muted: #71717a;
  --accent-light: rgba(124,58,237,0.1);
  --shadow: 0 8px 32px rgba(0,0,0,0.1);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.07);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--t), color var(--t);
  overflow-x: hidden;
}

/* ===== AD SLOTS ===== */
.ad-slot {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  flex-direction: column;
  gap: 4px;
  transition: background var(--t);
}
.ad-label { font-size: 10px; opacity: 0.5; }
.ad-banner-top {
  width: 100%; height: 90px;
  border-radius: 0;
  border-left: none; border-right: none; border-top: none;
}
.ad-rectangle { width: 300px; height: 250px; }
.ad-mid-section { display: flex; justify-content: center; padding: 32px 0; }

/* ===== HEADER ===== */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(9,9,11,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  transition: background var(--t);
}
[data-theme="light"] header { background: rgba(255,255,255,0.85); }

.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px; letter-spacing: -0.02em;
  color: var(--text); text-decoration: none;
}
.logo-icon {
  width: 30px; height: 30px;
  background: var(--gradient);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff;
}

.header-right { display: flex; align-items: center; gap: 8px; }

.usage-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px; color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
}
.usage-pill:hover { border-color: var(--accent); color: var(--text); }
.usage-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  transition: background var(--t);
}
.usage-dot.warn { background: var(--warning); }
.usage-dot.limit { background: var(--error); }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: all var(--t);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); border-color: var(--accent); }

.btn-pro {
  background: var(--gradient);
  color: #fff; border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: opacity var(--t);
  white-space: nowrap;
}
.btn-pro:hover { opacity: 0.88; }

/* ===== HERO ===== */
.hero {
  padding: 52px 24px 32px;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}
.hero h1 {
  font-size: clamp(28px, 5.5vw, 52px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.12;
  margin-bottom: 14px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub { font-size: 16px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }

.privacy-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--success-bg);
  border: 1px solid rgba(16,185,129,0.3);
  color: var(--success);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px; font-weight: 500;
  margin-bottom: 32px;
}

/* ===== DROP ZONE ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 44px 24px;
  cursor: pointer;
  transition: all var(--t);
  background: var(--surface);
}
.drop-zone:hover { border-color: var(--accent); background: var(--accent-light); }
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: scale(1.015);
}
.drop-zone-icon { font-size: 52px; margin-bottom: 12px; display: block; }
.drop-zone h3 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.drop-zone > p { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; }
.btn-group { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.supported-formats { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.supported-formats span { color: #a78bfa; font-weight: 500; }

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all var(--t);
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all var(--t);
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--accent); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--t);
  font-family: var(--font);
}
.btn-ghost:hover { color: var(--error); border-color: var(--error); }

.btn-convert-all {
  background: var(--gradient); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: opacity var(--t);
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font);
}
.btn-convert-all:hover { opacity: 0.88; }
.btn-convert-all:disabled { opacity: 0.35; cursor: not-allowed; }

/* ===== CONTAINER & QUEUE CONTROLS ===== */
.container { max-width: 920px; margin: 0 auto; padding: 0 16px; }

.queue-controls {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 16px 0; flex-wrap: wrap; gap: 12px;
}
.queue-controls.visible { display: flex; }
.queue-stats { font-size: 14px; color: var(--text-muted); }
.queue-stats strong { color: var(--text); font-size: 16px; }
.queue-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== QUEUE ITEMS ===== */
.queue { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }

.queue-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color var(--t), box-shadow var(--t);
}
.queue-item.converting { border-color: rgba(124,58,237,0.5); box-shadow: 0 0 0 1px rgba(124,58,237,0.15); }
.queue-item.done { border-color: rgba(16,185,129,0.35); }
.queue-item.error { border-color: rgba(239,68,68,0.35); }
.queue-item.skipped { border-color: rgba(245,158,11,0.35); }

.queue-item-top {
  display: flex; align-items: center; gap: 12px;
}
.file-thumb {
  width: 46px; height: 46px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0; overflow: hidden;
}
.file-thumb img { width: 46px; height: 46px; object-fit: cover; border-radius: var(--radius-xs); }

.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.file-meta { font-size: 12px; color: var(--text-muted); }

.file-controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.arrow { color: var(--text-muted); font-size: 13px; }

select.fmt-sel {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 5px 8px; font-size: 12px;
  cursor: pointer; outline: none;
  font-family: var(--font);
  transition: border-color var(--t);
}
select.fmt-sel:hover, select.fmt-sel:focus { border-color: var(--accent); }

.quality-wrap {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-muted);
}
.quality-wrap input[type=range] {
  width: 68px; accent-color: var(--accent); cursor: pointer;
}
.q-val {
  font-size: 11px; font-family: var(--mono);
  color: #a78bfa; min-width: 22px; text-align: right;
}

.item-btns { display: flex; gap: 6px; margin-left: 4px; }
.btn-sm {
  width: 30px; height: 30px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t);
}
.btn-sm:hover { background: var(--surface-3); color: var(--text); border-color: var(--accent); }
.btn-sm.dl { color: var(--success); }
.btn-sm.dl:hover { border-color: var(--success); background: var(--success-bg); }
.btn-sm.rm:hover { color: var(--error); border-color: var(--error); }
.btn-sm:disabled { opacity: 0.25; cursor: not-allowed; }

/* Progress */
.progress-row {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
}
.progress-track {
  flex: 1; height: 4px;
  background: var(--surface-2); border-radius: 2px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--gradient);
  border-radius: 2px; transition: width 0.35s ease; width: 0%;
}
.progress-fill.indeterminate {
  width: 38% !important;
  animation: indeterminate 1.5s ease-in-out infinite;
}
@keyframes indeterminate {
  0%   { transform: translateX(-200%); }
  100% { transform: translateX(320%); }
}
.progress-meta {
  font-size: 11px; color: var(--text-muted);
  font-family: var(--mono); min-width: 100px; text-align: right;
}
.status-badge {
  font-size: 11px; padding: 2px 8px;
  border-radius: 10px; font-weight: 500; white-space: nowrap;
}
.s-pending  { background: var(--surface-2); color: var(--text-muted); }
.s-converting { background: var(--accent-light); color: #a78bfa; border: 1px solid rgba(124,58,237,0.3); }
.s-done     { background: var(--success-bg); color: var(--success); }
.s-error    { background: var(--error-bg);   color: var(--error); }
.s-skipped  { background: var(--warning-bg); color: var(--warning); }

.error-msg { font-size: 11px; color: var(--error); margin-top: 5px; }

/* FFmpeg notice */
.ffmpeg-notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 13px; color: var(--text-2);
  display: none; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.ffmpeg-notice.visible { display: flex; }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-header {
  padding: 20px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px 24px 24px; }

/* Settings */
.settings-section-title {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 12px;
}
.settings-group { margin-bottom: 16px; }
.settings-group label {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px;
}
.settings-group small { font-size: 11px; color: var(--text-muted); display: block; margin-top: 4px; }
.settings-group select {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 14px; outline: none;
  font-family: var(--font); transition: border-color var(--t);
}
.settings-group select:focus { border-color: var(--accent); }
.settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-slider-val { font-family: var(--mono); font-size: 12px; color: #a78bfa; }
.settings-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.toggle-row > span { font-size: 13px; color: var(--text-2); }
.toggle {
  width: 38px; height: 22px;
  background: var(--surface-3); border-radius: 11px;
  position: relative; cursor: pointer;
  transition: background var(--t); border: none; flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content: ''; position: absolute;
  width: 16px; height: 16px;
  background: #fff; border-radius: 50%;
  top: 3px; left: 3px; transition: left var(--t);
}
.toggle.on::after { left: 19px; }

.free-tier-bar { margin-bottom: 0; }
.tier-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.tier-track { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.tier-fill { height: 100%; background: var(--gradient); border-radius: 3px; transition: width 0.5s ease; }

/* Pro Modal */
.pro-gradient-header {
  background: var(--gradient);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 36px 24px; text-align: center; color: #fff;
}
.crown { font-size: 44px; margin-bottom: 8px; }
.pro-gradient-header h2 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.pro-gradient-header p { font-size: 15px; opacity: 0.87; }
.pro-features { list-style: none; margin: 16px 0; }
.pro-features li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.pro-features li:last-child { border-bottom: none; }
.check { color: var(--success); font-size: 16px; font-weight: 700; }
.pro-price {
  text-align: center; margin: 16px 0; padding: 18px;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.price {
  font-size: 34px; font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.price-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.btn-pro-cta {
  width: 100%; background: var(--gradient); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 14px; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: opacity var(--t); font-family: var(--font);
}
.btn-pro-cta:hover { opacity: 0.9; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 16px;
  font-size: 13px; box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  max-width: 300px; display: flex; align-items: center; gap: 8px;
}
@keyframes toastIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error); }
.toast.info    { border-left: 3px solid var(--accent); }

/* ===== FOOTER ===== */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px; text-align: center;
  color: var(--text-muted); font-size: 12px; margin-top: 20px;
}
footer a { color: #a78bfa; text-decoration: none; }
footer a:hover { text-decoration: underline; }
.footer-badges { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.footer-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px; font-size: 11px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  header { padding: 0 12px; }
  .hero { padding: 28px 12px 20px; }
  #usage-text { display: none; }
  .btn-pro span { display: none; }
  .file-controls { gap: 5px; }
  .quality-wrap input[type=range] { width: 50px; }
  .settings-row { grid-template-columns: 1fr; }
  .queue-controls { flex-direction: column; align-items: flex-start; }
}