/* ── Design tokens ── */
:root {
  --bg: #080c18;
  --bg-elevated: #0d1224;
  --surface: #121829;
  --surface-2: #0f1526;
  --surface-glass: rgba(18, 24, 41, 0.72);
  --text: #eef1f8;
  --text-secondary: #9aa4be;
  --text-muted: #6b7590;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --pink: #ec4899;
  --cyan: #22d3ee;
  --grad: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --grad-subtle: linear-gradient(135deg, rgba(99,102,241,.15) 0%, rgba(168,85,247,.1) 100%);
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --err: #f87171;
  --err-bg: rgba(248, 113, 113, 0.12);
  --warn-bg: rgba(99, 102, 241, 0.15);
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-card: 0 4px 6px -1px rgba(0,0,0,.3), 0 24px 48px -12px rgba(0,0,0,.5);
  --shadow-glow: 0 0 60px -12px var(--accent-glow);
  --font-sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html, body { margin: 0; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── Background effects ── */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
}

.orb-1 {
  width: 600px; height: 600px;
  top: -200px; right: -100px;
  background: radial-gradient(circle, rgba(99,102,241,.4) 0%, transparent 70%);
}

.orb-2 {
  width: 500px; height: 500px;
  bottom: -150px; left: -100px;
  background: radial-gradient(circle, rgba(236,72,153,.3) 0%, transparent 70%);
}

.orb-3 {
  width: 400px; height: 400px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(34,211,238,.12) 0%, transparent 70%);
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148,163,184,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.04) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 20%, transparent 70%);
}

/* ── Navigation ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(8, 12, 24, 0.75);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-mark.sm {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.nav-links a:hover {
  color: var(--text);
  background: rgba(255,255,255,.05);
}

.nav-links a:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

.nav-cta {
  background: var(--grad) !important;
  color: #fff !important;
  font-weight: 600 !important;
  margin-left: 4px;
}

.nav-cta:hover {
  filter: brightness(1.1);
  background: var(--grad) !important;
}

/* ── Hero ── */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 24px 80px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-light);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.pill-icon { flex-shrink: 0; opacity: 0.9; }

.hero-copy h1 {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 1.1;
  margin: 24px 0 20px;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.7;
  max-width: 480px;
  margin: 0;
}

.checks {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checks li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--text-secondary);
}

.checks li svg {
  color: var(--ok);
  flex-shrink: 0;
}

.hero-stats {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.stat { display: flex; flex-direction: column; gap: 2px; }

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.stat-divider {
  width: 1px;
  height: 36px;
  background: var(--border-strong);
}

/* ── App card (converter) ── */
.app-card {
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.card-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 16px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.card-title {
  color: var(--text-muted);
  font-size: 13px;
  margin-left: 8px;
  font-weight: 500;
}

/* ── Dropzone ── */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  background: rgba(255,255,255,.02);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  cursor: pointer;
}

.dropzone:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.04);
}

.dropzone:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 3px;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.dz-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--grad-subtle);
  color: var(--accent-light);
  margin-bottom: 8px;
}

.dz-main {
  font-size: 18px;
  font-weight: 600;
  margin: 12px 0 6px;
  color: var(--text);
}

.dz-sub {
  color: var(--text-secondary);
  margin: 0;
  font-size: 15px;
}

.dz-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-light);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 2px;
  border-radius: 4px;
  transition: color var(--transition);
}

.link-btn:hover { color: var(--pink); }

.link-btn:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

/* ── Queue ── */
.queue {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.queue:empty { display: none; }

.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition);
}

.queue-item:hover { border-color: var(--border-strong); }

.qi-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.qi-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.qi-status.queued { background: rgba(154,163,192,.12); color: var(--text-muted); }
.qi-status.converting { background: var(--warn-bg); color: var(--accent-light); }
.qi-status.done { background: var(--ok-bg); color: var(--ok); }
.qi-status.error { background: var(--err-bg); color: var(--err); }

.qi-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  min-height: 32px;
}

.qi-btn:hover:not([disabled]) {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}

.qi-btn:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

.qi-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Buttons ── */
.card-actions { margin-top: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  transition: filter var(--transition), transform var(--transition), box-shadow var(--transition);
  min-height: 44px;
}

.btn.primary {
  background: var(--grad);
  border: none;
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn.primary:not([disabled]):hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn.primary:not([disabled]):active {
  transform: translateY(0);
}

.btn.primary[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

/* ── Sections (How it works, Formats) ── */
.section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 24px;
}

.section-header {
  text-align: center;
  max-width: 560px;
  margin: 0 auto 48px;
}

.section-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-light);
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 16px;
  margin: 0;
  line-height: 1.6;
}

/* Steps */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.step-card {
  position: relative;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.step-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px -8px rgba(0,0,0,.4);
}

.step-num {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 0.5;
  font-family: var(--font-mono);
}

.step-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--grad-subtle);
  color: var(--accent-light);
  margin-bottom: 20px;
}

.step-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
}

.step-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.6;
}

/* Format grid */
.format-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.format-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), background var(--transition);
}

.format-chip:hover {
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.04);
}

.format-ext {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-light);
}

.format-name {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  margin-top: 40px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}

.footer-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.footer-note a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-note a:hover { color: var(--pink); }

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 18, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
  animation: fadeIn 200ms ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal.hidden { display: none; }

.modal-box {
  width: min(900px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  animation: slideUp 250ms ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.toggle {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}

.toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: background var(--transition), color var(--transition);
  min-height: 32px;
}

.toggle-btn.active {
  background: var(--grad);
  color: #fff;
}

.toggle-btn:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 1px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255,255,255,.04);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

.preview-body {
  padding: 24px 28px;
  overflow: auto;
  flex: 1;
}

.preview-body.raw {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: #cdd5f0;
  margin: 0;
}

.preview-body.rendered { line-height: 1.7; }

.preview-body.rendered h1,
.preview-body.rendered h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3em;
  margin-top: 1.5em;
}

.preview-body.rendered h1:first-child,
.preview-body.rendered h2:first-child { margin-top: 0; }

.preview-body.rendered table { border-collapse: collapse; width: 100%; }

.preview-body.rendered td,
.preview-body.rendered th {
  border: 1px solid var(--border);
  padding: 8px 12px;
}

.preview-body.rendered code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.preview-body.rendered pre {
  background: var(--surface-2);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.preview-body.rendered a { color: var(--accent-light); }

.hidden { display: none; }

.modal-foot {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Local install hint in dropzone ── */
.dz-local {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.dz-local code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(255,255,255,.06);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent-light);
}

/* Only hide the hint when we're actually running on localhost */
.is-local .dz-local { display: none; }

/* ── Install section ── */
.install-section { border-top: 1px solid var(--border); }

.install-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  max-width: 760px;
  margin: 0 auto;
}

.install-card {
  display: flex;
  gap: 20px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.install-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--grad-subtle);
  border: 1px solid rgba(99,102,241,.25);
  color: var(--accent-light);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
  display: grid;
  place-items: center;
}

.install-body h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.install-cmd {
  margin: 0;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-light);
  overflow-x: auto;
}

.install-cmd code { font: inherit; }

.install-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .hero { gap: 48px; }
  .format-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .install-cards { grid-template-columns: 1fr; }

  .nav-links a:not(.nav-cta) { display: none; }

  .hero {
    grid-template-columns: 1fr;
    padding: 40px 20px 60px;
    gap: 40px;
  }

  .hero-stats {
    flex-wrap: wrap;
    gap: 20px;
  }

  .stat-divider { display: none; }

  .steps {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .section { padding: 60px 20px; }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .queue-item {
    flex-wrap: wrap;
  }

  .qi-name {
    flex: 1 1 100%;
    order: -1;
    margin-bottom: 4px;
  }
}

@media (max-width: 480px) {
  .format-grid { grid-template-columns: 1fr; }

  .modal-head {
    flex-wrap: wrap;
    gap: 10px;
  }

  .modal-title { flex: 1 1 100%; }
}
