:root {
  --bg: #f7fbfc;
  --surface: #ffffff;
  --ink: #0f2a33;
  --ink-soft: #46626d;
  --ink-faint: #7a929b;
  --accent: #0891b2;
  --accent-deep: #0e7490;
  --accent-soft: #e0f5fa;
  --cta: #16a34a;
  --border: #dcebef;
  --shadow-sm: 0 1px 2px rgba(15, 42, 51, 0.05);
  --shadow-md: 0 6px 24px -8px rgba(15, 42, 51, 0.12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 42, 51, 0.18);
  --radius: 20px;
  --radius-sm: 12px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(620px 380px at 18% -5%, rgba(34, 211, 238, 0.16), transparent 65%),
    radial-gradient(720px 420px at 85% 0%, rgba(8, 145, 178, 0.10), transparent 65%),
    radial-gradient(800px 500px at 50% 110%, rgba(165, 243, 252, 0.18), transparent 70%);
}

/* ---------- Header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent-deep);
  background: rgba(224, 245, 250, 0.75);
  border: 1px solid rgba(8, 145, 178, 0.18);
  border-radius: 999px;
  padding: 6px 13px;
  backdrop-filter: blur(8px);
}

/* ---------- Layout ---------- */

.container {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

.hero {
  text-align: center;
  padding: 44px 0 36px;
}

.hero h1 {
  font-size: clamp(34px, 5.5vw, 54px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.12;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent) 10%, #22d3ee 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero-sub {
  max-width: 520px;
  margin: 18px auto 0;
  font-size: 16.5px;
  color: var(--ink-soft);
}

.stage { margin: 0 auto; max-width: 660px; }

/* ---------- Dropzone ---------- */

.dropzone {
  position: relative;
  background: var(--surface);
  border: 1.5px dashed rgba(8, 145, 178, 0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: border-color 200ms ease, box-shadow 250ms ease, transform 250ms ease, background-color 200ms ease;
  outline: none;
}

.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.dropzone:focus-visible {
  outline: 3px solid rgba(8, 145, 178, 0.35);
  outline-offset: 3px;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.012);
  box-shadow: var(--shadow-lg);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 32px;
}

.dropzone-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--accent-deep);
  background: linear-gradient(145deg, var(--accent-soft), #f0fbfd);
  border: 1px solid rgba(8, 145, 178, 0.15);
  margin-bottom: 20px;
  transition: transform 250ms ease;
}

.dropzone:hover .dropzone-icon { transform: translateY(-3px); }

.dropzone-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.dropzone-hint {
  margin-top: 6px;
  font-size: 14.5px;
  color: var(--ink-soft);
}

.link-accent { color: var(--accent-deep); font-weight: 600; }

kbd {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  background: #eef5f7;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
}

.dropzone-formats {
  margin-top: 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.upload-error {
  margin-top: 14px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: #b42318;
}

/* ---------- Processing ---------- */

.processing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.processing-preview {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-width: 360px;
  box-shadow: var(--shadow-sm);
}

.processing-preview img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  background: #eef5f7;
}

.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 34%;
  background: linear-gradient(to bottom, transparent, rgba(34, 211, 238, 0.28) 45%, rgba(8, 145, 178, 0.45) 50%, rgba(34, 211, 238, 0.28) 55%, transparent);
  animation: scan 2.2s ease-in-out infinite;
}

@keyframes scan {
  0%, 100% { top: -34%; }
  50% { top: 100%; }
}

.processing-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-soft);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-track {
  width: 100%;
  max-width: 360px;
  height: 6px;
  margin-top: 16px;
  border-radius: 999px;
  background: #e8f2f5;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #22d3ee);
  transition: width 300ms ease;
}

.processing-note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
  max-width: 380px;
}

/* ---------- Result ---------- */

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 18px;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.view-toggle {
  display: inline-flex;
  background: #eef5f7;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.toggle-btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.toggle-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.crisp-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  margin-right: auto;
  margin-left: 4px;
}

.crisp-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.crisp-toggle .switch {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #d6e5ea;
  position: relative;
  flex-shrink: 0;
  transition: background-color 200ms ease;
}

.crisp-toggle .switch::after {
  content: '';
  position: absolute;
  top: 2.5px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 42, 51, 0.25);
  transition: transform 200ms ease;
}

.crisp-toggle input:checked + .switch { background: var(--accent); }
.crisp-toggle input:checked + .switch::after { transform: translateX(13px); }
.crisp-toggle input:focus-visible + .switch {
  outline: 3px solid rgba(8, 145, 178, 0.4);
  outline-offset: 2px;
}

.crisp-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.25;
  display: flex;
  flex-direction: column;
}

.crisp-label small {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faint);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.btn-ghost:hover { color: var(--ink); border-color: #b9d6dd; background: #f4fafb; }

.result-preview {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 240px;
}

.checkerboard {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #e6edf0 25%, transparent 25%, transparent 75%, #e6edf0 75%),
    linear-gradient(45deg, #e6edf0 25%, transparent 25%, transparent 75%, #e6edf0 75%);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
}

.result-preview img {
  display: block;
  max-width: 100%;
  max-height: 440px;
  object-fit: contain;
}

.result-preview img[hidden] { display: none; }

.refine-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px 14px;
  background: #f4fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.refine-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.refine-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 13px;
  cursor: pointer;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.btn-chip small {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faint);
}

.btn-chip:hover { border-color: var(--accent); color: var(--accent-deep); }

.btn-chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.btn-chip[aria-pressed="true"] small { color: var(--accent-deep); opacity: 0.75; }

.btn-chip:disabled { opacity: 0.55; cursor: default; }

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  padding: 13px 22px;
  cursor: pointer;
  flex: 1;
  min-width: 180px;
  transition: background-color 200ms ease, box-shadow 200ms ease, border-color 200ms ease, color 200ms ease;
}

.btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border: none;
  box-shadow: 0 8px 20px -8px rgba(8, 145, 178, 0.55);
}

.btn-primary:hover { box-shadow: 0 10px 26px -8px rgba(8, 145, 178, 0.7); background: linear-gradient(135deg, #0aa0c4, var(--accent)); }

.btn-secondary {
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover { border-color: var(--accent); color: var(--accent-deep); background: #f4fbfd; }

.btn-secondary.copied { border-color: var(--cta); color: var(--cta); background: #f2fbf5; }

.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-ghost:focus-visible, .toggle-btn:focus-visible, .dropzone:focus-visible {
  outline: 3px solid rgba(8, 145, 178, 0.4);
  outline-offset: 2px;
}

/* ---------- Features ---------- */

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 72px;
}

.feature {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 24px 22px;
  backdrop-filter: blur(6px);
  transition: box-shadow 250ms ease, border-color 250ms ease;
}

.feature:hover { box-shadow: var(--shadow-md); border-color: #c4dfe6; }

.feature-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--accent-deep);
  background: var(--accent-soft);
  margin-bottom: 14px;
}

.feature h3 {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 5px;
}

.feature p {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ---------- Footer & toast ---------- */

.site-footer {
  text-align: center;
  padding: 26px 24px;
  font-size: 13px;
  color: var(--ink-faint);
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-soft);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 180ms ease, border-color 180ms ease;
}

.footer-link:hover { color: var(--accent-deep); border-color: var(--accent-deep); }

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  padding: 11px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: toast-in 250ms ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Responsive & motion ---------- */

@media (max-width: 760px) {
  .features { grid-template-columns: 1fr; }
  .hero { padding: 28px 0 28px; }
  .dropzone-inner { padding: 48px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .scan-line { display: none; }
}
