/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --ink: #10231f;
  --ink-soft: #3d524c;
  --muted: #6b7c76;
  --line: #d7e4df;
  --paper: #f6fbf8;
  --card: #ffffff;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-soft: #ccfbf1;
  --amber: #ea580c;
  --ok: #15803d;
  --err: #b42318;

  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;

  --gutter: clamp(1rem, 4vw, 1.75rem);
  --section-gap: clamp(2.75rem, 7vw, 5rem);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ecfdf7;
    --ink-soft: #c5d5cf;
    --muted: #9db0aa;
    --line: #24403b;
    --paper: #0b1614;
    --card: #12201d;
    --teal: #2dd4bf;
    --teal-dark: #5eead4;
    --teal-soft: #134e4a;
    --amber: #fb923c;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
  padding-bottom: 88px;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 {
  text-wrap: balance;
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 700;
}
h1, .section__title { font-family: var(--display); }
::selection { background: var(--teal); color: #fff; }
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  border-radius: 4px;
}

/* =============================================================
   3. Utilities
   ============================================================= */
.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--card); color: var(--teal);
  z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }
.container { width: min(100% - var(--gutter) * 2, 1120px); margin-inline: auto; }
.container--narrow { width: min(100%, 760px); margin-inline: auto; }
.noscript {
  padding: 1rem 1.1rem;
  background: #fff4e5;
  color: #9a3412;
  border-radius: 12px;
  margin-bottom: 1rem;
}

/* =============================================================
   4. Header
   ============================================================= */
.header {
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(12px);
}
.header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.9rem 0;
}
.header__logo { display: flex; align-items: center; gap: 0.65rem; font-weight: 700; }
.header__logo-img { height: 40px; width: auto; border-radius: 4px; }
.header__mark {
  width: 2rem; height: 2rem; border-radius: 9px;
  background: var(--teal); color: #fff;
  display: grid; place-items: center;
  font-size: 0.78rem; letter-spacing: -0.04em;
}
.header__nav { display: flex; gap: 1.1rem; font-size: 0.92rem; font-weight: 600; color: var(--ink-soft); }
.header__nav a:hover { color: var(--teal); }
@media (max-width: 539px) {
  .header__nav a:nth-child(2) { display: none; }
}

/* =============================================================
   5. Hero + tool
   ============================================================= */
.hero { padding: clamp(1.6rem, 5vw, 3.2rem) 0 1.4rem; }
.hero__eyebrow {
  text-align: center; color: var(--teal); font-weight: 700;
  font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 0.7rem;
}
.hero__title {
  font-size: clamp(1.85rem, 6vw, 3.15rem);
  text-align: center; margin-bottom: 0.8rem;
}
.hero__title-accent { color: var(--teal); }
.hero__subtitle {
  text-align: center; color: var(--ink-soft);
  max-width: 40rem; margin: 0 auto 1.6rem;
}

.hero__workspace {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}
@media (min-width: 1100px) {
  .hero__workspace {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}
.hero__ad {
  display: none;
  position: relative;
  z-index: 1;
  isolation: isolate;
  overflow: hidden;
  width: 300px;
  max-width: 100%;
}
.hero__ad .ad-slot {
  margin: 0;
  width: 300px;
  max-width: 100%;
}
@media (min-width: 1100px) {
  .hero__ad { display: block; }
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.tool-card {
  position: relative;
  z-index: 20;
  isolation: isolate;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 3vw, 1.8rem);
  box-shadow: 0 18px 50px rgba(16, 35, 31, 0.07);
  min-height: 320px;
}
.tool-card__zone { display: none; width: 100%; }
.tool-card[data-state="idle"] [data-zone="idle"] { display: block; }
.tool-card[data-state="loading-engine"] [data-zone="loading-engine"],
.tool-card[data-state="working"] [data-zone="working"],
.tool-card[data-state="error"] [data-zone="error"] {
  display: flex; min-height: 240px; align-items: center;
}
.tool-card[data-state="done"] [data-zone="done"] { display: block; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.85rem; padding: 2.2rem 1.2rem; width: 100%;
  border: 2px dashed color-mix(in srgb, var(--teal) 35%, var(--line));
  border-radius: 14px; background: color-mix(in srgb, var(--teal-soft) 45%, var(--card));
  cursor: pointer; text-align: center; font: inherit; color: inherit;
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--teal);
  transform: translateY(-1px);
}
.dropzone__icon { width: 42px; height: 42px; color: var(--teal); }
.dropzone__text { font-size: 1.05rem; }
.dropzone__text strong { color: var(--teal-dark); }
.dropzone__hint { font-size: 0.86rem; color: var(--muted); }

.btn-camera {
  display: none;
  align-items: center; justify-content: center; gap: 0.5rem;
  width: 100%; margin-top: 0.85rem;
  padding: 0.9rem 1.2rem;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); font: inherit; font-weight: 700; color: inherit; cursor: pointer;
}
.btn-camera svg { width: 20px; height: 20px; }
@media (max-width: 719px), (pointer: coarse) {
  .btn-camera { display: inline-flex; }
}

.progress-section {
  display: flex; flex-direction: column; align-items: center; gap: 0.85rem;
  width: 100%; max-width: 28rem; margin: 0 auto; text-align: center;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--line); border-top-color: var(--teal);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar {
  width: 100%; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden;
}
.progress-bar__fill {
  height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), #14b8a6);
  border-radius: 999px; transition: width 0.3s var(--ease-out);
}
.progress-section__label { font-weight: 700; }
.progress-section__hint { color: var(--muted); font-size: 0.88rem; }

.result-preview {
  display: grid; grid-template-columns: 1fr; gap: 1.1rem; margin-bottom: 1.2rem;
}
@media (min-width: 960px) {
  .result-preview { grid-template-columns: 1fr 1fr; }
}
.result-preview__heading {
  font-family: var(--sans); font-size: 0.92rem; margin-bottom: 0.55rem;
}
.result-preview__heading span { color: var(--muted); font-weight: 500; }
.result-preview__img-wrapper,
.result-preview__editor-wrapper {
  border: 1px solid var(--line); border-radius: 12px; overflow: auto;
  background: var(--paper); min-height: 280px; max-height: 420px;
}
.result-preview__img-wrapper { display: flex; align-items: flex-start; justify-content: center; }
.result-preview__img-wrapper img { width: 100%; object-fit: contain; }

.preview-editor {
  min-height: 280px; padding: 1rem 1.1rem;
  font-size: 0.95rem; line-height: 1.55; outline: none;
  background: var(--card);
}
.preview-editor p { margin: 0 0 0.7em; }
.preview-editor p.is-spaced { margin-top: 1.15em; }
.preview-editor ul { margin: 0 0 0.85em; padding-left: 1.2em; }
.preview-editor li { margin: 0.15em 0; }

/* Page separator for multiple images */
.page-separator {
  margin: 1.5em 0;
  padding: 0.8em 1em;
  text-align: center;
  font-weight: 600;
  font-size: 0.9em;
  color: var(--teal);
  background: color-mix(in srgb, var(--teal-soft) 20%, var(--card));
  border-top: 2px dashed var(--teal-soft);
  border-bottom: 2px dashed var(--teal-soft);
  border-radius: 4px;
}

.result-actions {
  position: relative;
  z-index: 21;
  display: flex; flex-wrap: wrap; gap: 0.7rem; justify-content: center; margin-bottom: 0.7rem;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.85rem 1.15rem; border-radius: 12px; font-weight: 700; font-size: 0.95rem;
  transition: transform 0.2s var(--ease-out), background 0.2s var(--ease-out);
}
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary.is-ok { background: var(--ok); }
.btn--star {
  background: var(--teal); color: #fff;
  padding: 0.95rem 1.35rem; font-size: 1rem;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--teal) 28%, transparent);
}
.btn--secondary { border: 1px solid var(--line); background: var(--card); }
.btn--ghost { color: var(--muted); font-weight: 600; }
.btn:hover { transform: translateY(-1px); }
.btn-reset { display: block; margin: 0.4rem auto 0; color: var(--muted); font-weight: 600; }
.btn-reset:hover { color: var(--teal); }

.error-message {
  display: flex; flex-direction: column; align-items: center; gap: 0.9rem;
  text-align: center; padding: 1.4rem; width: 100%;
}
.error-message p { color: var(--err); font-weight: 600; }

.privacy-badge {
  margin-top: 1.1rem; text-align: center;
  padding: 0.95rem 1.1rem; border-radius: 14px;
  background: var(--teal-soft); color: var(--teal-dark);
}
.privacy-badge span { display: block; margin-top: 0.25rem; font-size: 0.88rem; font-weight: 500; opacity: 0.9; }

/* =============================================================
   6. Ads + layout
   ============================================================= */
.ad-slot {
  margin: 1.4rem auto;
  border: 1px dashed var(--line);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--card) 70%, transparent);
  min-height: 90px;
  overflow: hidden;
  isolation: isolate;
  position: relative;
  z-index: 1;
}
.ad-slot__label {
  font-size: 0.72rem; color: var(--muted);
  letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700;
}
.ad-slot--leaderboard { max-width: 728px; min-height: 90px; }
.ad-slot--inline { max-width: 760px; min-height: 250px; }
.ad-slot--sidebar { min-height: 250px; width: 100%; max-width: 300px; margin: 0; position: sticky; top: 5rem; }

.content-shell { width: min(100% - var(--gutter) * 2, 1120px); margin: 0 auto 2rem; }
.sidebar { display: none; }
@media (min-width: 1280px) {
  .content-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 2rem; align-items: start;
  }
  .sidebar { display: block; padding-top: var(--section-gap); }
}

/* =============================================================
   7. Sections
   ============================================================= */
.section { padding: var(--section-gap) 0; }
.section--how, .section--why { background: transparent; }
.section__title {
  font-size: clamp(1.55rem, 3.4vw, 2.2rem);
  text-align: center; margin-bottom: 1.6rem;
}
.steps, .features, .use-cases {
  display: grid; gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .steps, .features, .use-cases { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 960px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
}
.step, .feature, .use-case {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 1.2rem 1.15rem;
}
.step { text-align: center; }
.step__icon {
  width: 3.1rem; height: 3.1rem; margin: 0 auto 0.8rem; padding: 0.7rem;
  border-radius: 12px; background: var(--teal-soft); color: var(--teal);
}
.step__title, .feature__title, .use-case__title {
  font-family: var(--sans); font-size: 1.05rem; margin-bottom: 0.45rem;
}
.step__text, .feature__text, .use-case__text { color: var(--ink-soft); font-size: 0.95rem; }

.prose p { color: var(--ink-soft); margin-bottom: 0.95rem; }
.prose strong { color: var(--ink); }

.faq { max-width: 760px; margin: 0 auto; }
.faq__item { border-bottom: 1px solid var(--line); padding: 1.05rem 0; }
.faq__item:first-child { border-top: 1px solid var(--line); }
.faq__question {
  font-size: 1.02rem; font-weight: 700; cursor: pointer;
  list-style: none; display: flex; justify-content: space-between; gap: 1rem;
}
.faq__question::-webkit-details-marker { display: none; }
.faq__question::after { content: "+"; color: var(--teal); font-size: 1.4rem; }
.faq__item[open] .faq__question::after { transform: rotate(45deg); }
.faq__answer { padding-top: 0.7rem; color: var(--ink-soft); }

/* =============================================================
   8. Footer
   ============================================================= */
.footer { padding: 1.6rem 0 2rem; border-top: 1px solid var(--line); }
.footer__content {
  display: flex; flex-direction: column; gap: 0.8rem; align-items: center; text-align: center;
}
@media (min-width: 720px) {
  .footer__content { flex-direction: row; justify-content: space-between; text-align: left; }
}
.footer__text, .footer__links a { font-size: 0.88rem; color: var(--muted); }
.footer__links { display: flex; gap: 1.1rem; }
.footer__links a:hover { color: var(--teal); }

.legal-page { padding: 2.5rem 0 4rem; max-width: 720px; }
.legal-page h1 { font-size: 2rem; margin-bottom: 1rem; }
.legal-page h2 { font-family: var(--sans); font-size: 1.15rem; margin: 1.4rem 0 0.5rem; }
.legal-page p { color: var(--ink-soft); margin-bottom: 0.8rem; }

/* =============================================================
   9. Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner { animation: none; }
}


/* Custom bullet symbols in preview */
.result-preview__editor-wrapper ul li {
  list-style: none;
  position: relative;
  padding-left: 1.5rem;
}

.result-preview__editor-wrapper ul li::before {
  content: attr(data-symbol) " ";
  position: absolute;
  left: 0;
  font-weight: 500;
  color: var(--primary);
}


/* Comparison Section */
.section--comparison {
  background: var(--bg-alt);
}

.comparison {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}

@media (min-width: 960px) {
  .comparison {
    grid-template-columns: 1fr 1fr;
  }
}

.comparison__col {
  background: var(--bg);
  border-radius: 12px;
  padding: 1.5rem;
  border: 2px solid var(--border);
}

.comparison__col--bad {
  border-color: rgba(239, 68, 68, 0.3);
}

.comparison__col--good {
  border-color: rgba(34, 197, 94, 0.3);
}

.comparison__badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.comparison__badge--bad {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.comparison__badge--good {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
}

.comparison__content {
  font-size: 0.875rem;
  line-height: 1.6;
}

.comparison__content p {
  margin-bottom: 0.75rem;
}

.comparison__content strong {
  color: var(--text);
  font-weight: 600;
}

.comparison__list {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
  list-style: none;
}

.comparison__list li {
  position: relative;
  margin-bottom: 0.25rem;
  padding-left: 0.5rem;
}

.comparison__list li::before {
  content: "•";
  position: absolute;
  left: -0.75rem;
  color: var(--primary);
  font-weight: bold;
}

.comparison__note {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-light);
  font-style: italic;
}

.comparison__features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.feature-card {
  text-align: center;
  padding: 1.5rem;
}

.feature-card__icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.feature-card__title {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.feature-card__text {
  font-size: 0.9375rem;
  color: var(--text-light);
  line-height: 1.5;
}

.comparison__disclaimer {
  text-align: center;
  color: var(--text-light);
  max-width: 700px;
  margin: 0 auto;
  padding: 1.5rem;
  background: rgba(37, 99, 235, 0.05);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}


/* =============================================================
   10. Table Styles for Document Preview
   ============================================================= */
.preview-editor table.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.85em 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.preview-editor table.doc-table.is-spaced {
  margin-top: 1.35em;
}

.preview-editor table.doc-table tr {
  border-bottom: 1px solid var(--line);
}

.preview-editor table.doc-table tr:last-child {
  border-bottom: none;
}

.preview-editor table.doc-table td {
  padding: 0.6rem 0.8rem;
  border-right: 1px solid var(--line);
  vertical-align: top;
}

.preview-editor table.doc-table td:last-child {
  border-right: none;
}

/* Form-style table (2 columns: label & value) */
.preview-editor table.doc-table:not(.doc-table--grid) td.table-label {
  font-weight: 600;
  background: color-mix(in srgb, var(--teal-soft) 30%, var(--card));
  color: var(--teal-dark);
  width: 35%;
  min-width: 120px;
}

.preview-editor table.doc-table:not(.doc-table--grid) td.table-value {
  background: var(--card);
  color: var(--ink);
  width: 65%;
}

/* Grid-style table (multiple columns) */
.preview-editor table.doc-table--grid td {
  background: var(--card);
  color: var(--ink);
  font-size: 0.88rem;
  padding: 0.5rem 0.7rem;
}

.preview-editor table.doc-table--grid tr:first-child td {
  background: color-mix(in srgb, var(--teal-soft) 25%, var(--card));
  font-weight: 600;
  color: var(--teal-dark);
}

/* Make tables responsive */
@media (max-width: 539px) {
  .preview-editor table.doc-table {
    font-size: 0.88rem;
  }
  
  .preview-editor table.doc-table td {
    padding: 0.5rem 0.6rem;
  }
  
  .preview-editor table.doc-table--grid {
    font-size: 0.78rem;
  }
  
  .preview-editor table.doc-table--grid td {
    padding: 0.4rem 0.5rem;
  }
}


/* ============================================================================
   Language Switcher
   ========================================================================= */

.lang-switcher {
  display: inline-flex;
  gap: 0.25rem;
  margin-left: 1.5rem;
  padding-left: 1.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.lang-switcher__btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-switcher__btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.lang-switcher__btn.active {
  background: #fff;
  border-color: #fff;
  color: var(--color-accent);
  cursor: default;
}

@media (max-width: 640px) {
  .lang-switcher {
    margin-left: auto;
    padding-left: 0;
    border-left: none;
  }
  
  .header__nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }
}
