/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #FAF9F7;
  --bg-soft: #F3F1EC;
  --bg-raise: #FFFFFF;
  --ink: #1F1B2E;
  --ink-soft: #635C77;
  --ink-faint: #9C93B0;
  --border: #E7E2F0;
  --border-strong: #D6CEE8;

  --accent: #6D28D9;
  --accent-dark: #5B21B6;
  --accent-soft: #EDE4FB;
  --accent-ink: #ffffff;

  --teal: #F0653E;
  --teal-soft: #FDE7DF;

  --success: #178A5B;
  --success-soft: #E3F6ED;
  --warn: #B5760A;
  --warn-soft: #FFF4DF;
  --danger: #D0342C;
  --danger-soft: #FCEAE8;

  --ad-bg: #F1EEF7;
  --ad-border: #D8CFEA;
  --ad-ink: #9A90AC;

  --sig-1: #FFF3C4;
  --sig-2: #FFD9A8;
  --sig-3: #FFB3AB;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(40,20,60,.06);
  --shadow: 0 8px 24px rgba(40,20,60,.09);
  --shadow-lg: 0 20px 60px rgba(40,20,60,.18);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --header-h: 68px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17141F;
    --bg-soft: #1D1926;
    --bg-raise: #221E2E;
    --ink: #F3F1F8;
    --ink-soft: #BCB4CC;
    --ink-faint: #83799A;
    --border: #322C42;
    --border-strong: #423A57;
    --accent-soft: #2E2145;
    --ad-bg: #241F32;
    --ad-border: #3A3350;
    --ad-ink: #8A8098;
    --success-soft: #133227;
    --warn-soft: #332608;
    --danger-soft: #35201f;
    --sig-1: #4A3E14;
    --sig-2: #4E3218;
    --sig-3: #4E211E;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video, canvas { 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; }
input, textarea, select { font: inherit; color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.12; letter-spacing: -0.01em; font-weight: 700; font-family: var(--serif); }
ul { list-style: none; padding: 0; }
::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* =============================================================
   3. Utilities
   ============================================================= */
.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--ink); color: var(--bg);
  z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.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;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: 20px;
}

.section { padding-block: clamp(2.5rem, 6vw, 5rem); }
.section-tight { padding-block: clamp(1.5rem, 4vw, 2.5rem); }

.eyebrow {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--sans);
  font-size: .78rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent);
}

.center { text-align: center; }
.muted { color: var(--ink-soft); }
.mt-1 { margin-top: 1rem; } .mt-2 { margin-top: 2rem; } .mt-3 { margin-top: 3rem; }

.icon { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(2rem, 4.4vw, 3.1rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.15rem; }
.subtitle { color: var(--ink-soft); font-family: var(--sans); font-size: clamp(1rem, 1.6vw, 1.15rem); max-width: 62ch; }
.subtitle.center { margin-inline: auto; }

/* =============================================================
   5. Components
   ============================================================= */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.4rem; border-radius: var(--radius-full);
  font-weight: 700; font-size: .96rem;
  transition: transform .18s var(--ease-out), background .18s var(--ease-out), box-shadow .18s var(--ease-out), border-color .18s var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(109,40,217,.28); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--bg-raise); color: var(--ink); border: 1.5px solid var(--border-strong); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { color: var(--ink); }
.btn-block { width: 100%; }
.btn-lg { padding: 1.05rem 1.8rem; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* Cards */
.card {
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}

/* Header / nav */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}
.site-header .container { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--serif); font-weight: 700; font-size: 1.12rem; letter-spacing: -.01em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: .95rem; font-family: var(--sans); flex-shrink: 0;
}
.main-nav { display: none; align-items: center; gap: 1.9rem; }
.main-nav a { font-weight: 600; font-size: .94rem; color: var(--ink-soft); transition: color .15s; }
.main-nav a:hover { color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: .6rem; }

.nav-toggle {
  display: flex; width: 40px; height: 40px; border-radius: 10px;
  align-items: center; justify-content: center; border: 1px solid var(--border-strong);
}
.nav-toggle svg { width: 20px; height: 20px; }

.mobile-nav {
  position: fixed; inset: var(--header-h) 0 0 0; z-index: 99;
  background: var(--bg); padding: 1.5rem 20px; display: none; overflow-y: auto;
}
.mobile-nav.is-open { display: block; }
.mobile-nav a { display: block; padding: .95rem 0; font-weight: 700; font-size: 1.15rem; border-bottom: 1px solid var(--border); }

@media (min-width: 720px) {
  .main-nav { display: flex; }
  .nav-toggle { display: none; }
}

/* Ad slots */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  background: var(--ad-bg); border: 1.5px dashed var(--ad-border);
  color: var(--ad-ink); border-radius: var(--radius);
  font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  margin-inline: auto; overflow: hidden; flex-direction: column; text-align: center; gap: .2rem;
}
.ad-slot small { display: block; font-weight: 500; letter-spacing: 0; text-transform: none; margin-top: .2rem; font-size: .72rem; }
.ad-leaderboard { width: 100%; max-width: 728px; min-height: 90px; }
.ad-incontent { width: 100%; max-width: 300px; min-height: 250px; }

/* Privacy badge / limits */
.tool-meta {
  display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; justify-content: center;
  margin-top: 1.1rem; font-size: .86rem; color: var(--ink-soft);
}
.tool-meta span { display: inline-flex; align-items: center; gap: .4rem; }
.tool-meta .icon { width: 16px; height: 16px; color: var(--success); }

/* =============================================================
   6. Sections
   ============================================================= */

.tool-hero { padding-block: clamp(2rem, 5vw, 3.2rem) 1rem; text-align: center; }
.tool-hero .eyebrow { justify-content: center; width: 100%; }
.tool-hero h1 { margin-top: .6rem; }
.tool-hero .subtitle { margin-top: .7rem; }

/* Tool card shell */
.tool-card {
  max-width: 820px; margin: 1.8rem auto 0; text-align: left;
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: clamp(1.2rem, 3vw, 2.1rem);
}

.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem; text-align: center; padding: clamp(1.4rem, 4vw, 2rem) 1.2rem;
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--bg-soft); cursor: pointer; transition: border-color .18s, background .18s;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-icon {
  width: 48px; height: 48px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.dropzone-icon .icon { width: 24px; height: 24px; }
.dropzone strong { font-size: .98rem; }
.dropzone span { color: var(--ink-faint); font-size: .82rem; }

.divider-or {
  display: flex; align-items: center; gap: .8rem; margin: 1.1rem 0;
  color: var(--ink-faint); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.divider-or::before, .divider-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.file-info-line {
  display: none; align-items: center; justify-content: space-between; gap: .6rem;
  margin-top: .7rem; padding: .6rem .9rem; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent-dark); font-size: .84rem; font-weight: 600;
}
.file-info-line button { font-size: .78rem; font-weight: 700; color: var(--ink-soft); flex-shrink: 0; }
.file-info-line button:hover { color: var(--danger); }

/* Generic tool controls */
.field { display: flex; flex-direction: column; gap: .4rem; }
.field label { font-size: .82rem; font-weight: 700; color: var(--ink-soft); }
.field textarea {
  padding: .8rem .95rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border-strong);
  background: var(--bg-raise); font-size: .96rem; resize: vertical; min-height: 160px; line-height: 1.6;
  font-family: var(--sans);
}
.field textarea:focus { border-color: var(--accent); }
.field-hint { font-size: .78rem; color: var(--ink-faint); }

/* Progress */
.progress-wrap { margin-top: 1.2rem; }
.progress-bar { height: 8px; border-radius: var(--radius-full); background: var(--bg-soft); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--teal)); transition: width .25s var(--ease-out); }
.progress-label { margin-top: .5rem; font-size: .85rem; color: var(--ink-soft); text-align: center; }

.result-actions { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; }
.reset-link { display: inline-block; margin-top: 1rem; font-size: .85rem; font-weight: 700; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }
.reset-link:hover { color: var(--accent); }

.error-box {
  text-align: center; padding: 1.4rem 1rem; border-radius: var(--radius);
  background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger);
  font-weight: 600; font-size: .92rem;
}

/* data-state visibility engine */
[data-state] .state-panel { display: none; }
[data-state="idle"] .state-idle,
[data-state="loading-engine"] .state-loading,
[data-state="working"] .state-working,
[data-state="done"] .state-done,
[data-state="error"] .state-error { display: block; }

/* Score ring (informe del detector) */
.score-ring { width: 140px; height: 140px; margin: 0 auto; position: relative; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .track { stroke: var(--border); }
.score-ring .fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s var(--ease-out), stroke .3s; }
.score-ring .label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.score-ring .label b { font-size: 1.8rem; font-family: var(--serif); }
.score-ring .label span { font-size: .72rem; color: var(--ink-soft); font-family: var(--sans); }

/* Informe: texto resaltado por frase, estilo detector académico */
.report-box {
  margin-top: 1.6rem; padding: 1.1rem 1.2rem; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--border);
  max-height: 340px; overflow-y: auto; font-size: .92rem; line-height: 1.75;
}
.report-box span { border-radius: 4px; padding: .04em 0; }
.report-box .sig-lvl-1 { background: var(--sig-1); }
.report-box .sig-lvl-2 { background: var(--sig-2); }
.report-box .sig-lvl-3 { background: var(--sig-3); }
.report-legend {
  display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; margin-top: .7rem;
  font-size: .76rem; color: var(--ink-faint);
}
.report-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.report-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.report-disclaimer {
  margin-top: .9rem; font-size: .78rem; color: var(--ink-faint); display: flex; gap: .5rem; align-items: flex-start;
}
.report-disclaimer .icon { width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; }

/* How it works */
.steps { display: grid; gap: 1.2rem; margin-top: 2rem; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { padding: 1.5rem; }
.step-num {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-family: var(--serif); margin-bottom: .9rem;
}

/* Audience */
.audience-grid { display: grid; gap: 1rem; margin-top: 1.8rem; }
@media (min-width: 720px) { .audience-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 960px) { .audience-grid { grid-template-columns: repeat(5, 1fr); } }
.audience-card { padding: 1.3rem; text-align: center; }
.audience-card h3 { font-size: .96rem; margin-bottom: .4rem; }
.audience-card p { font-size: .82rem; color: var(--ink-soft); font-family: var(--sans); }

/* FAQ */
.faq-list { max-width: 760px; margin: 1.8rem auto 0; display: flex; flex-direction: column; gap: .7rem; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-raise); overflow: hidden; }
.faq-item summary {
  padding: 1.05rem 1.2rem; font-weight: 700; cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.4rem; color: var(--accent); font-weight: 400; flex-shrink: 0; transition: transform .2s; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item .faq-body { padding: 0 1.2rem 1.1rem; color: var(--ink-soft); font-size: .92rem; }

/* SEO text block */
.prose { max-width: 760px; margin: 0 auto; color: var(--ink-soft); }
.prose h2, .prose h3 { color: var(--ink); margin-top: 1.6rem; margin-bottom: .6rem; }
.prose p { margin-bottom: 1rem; }
.prose ul, .prose ol { margin: 0 0 1rem 1.2rem; list-style: disc; }
.prose li { margin-bottom: .4rem; }

/* Privacy badge line under tool */
.privacy-line {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  margin-top: 1rem; font-size: .84rem; color: var(--success); font-weight: 700;
}

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); padding-block: 3rem 2rem; margin-top: 4rem; }
.footer-grid { display: grid; gap: 2rem; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.footer-col h4 { font-family: var(--sans); font-size: .85rem; margin-bottom: .8rem; }
.footer-col a { display: block; padding: .35rem 0; font-size: .88rem; color: var(--ink-soft); }
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  margin-top: 2.2rem; padding-top: 1.6rem; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center;
  font-size: .8rem; color: var(--ink-faint);
}

/* Toast (corner ad) */
.corner-toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 200; max-width: 300px;
  background: var(--ad-bg); border: 1.5px dashed var(--ad-border); border-radius: var(--radius);
  padding: .9rem 1rem; display: none; box-shadow: var(--shadow-lg);
}
.corner-toast.is-visible { display: block; animation: toastIn .35s var(--ease-out); }
.corner-toast .toast-close { position: absolute; top: 6px; right: 8px; font-size: 1rem; color: var(--ad-ink); }
.corner-toast .toast-label { font-size: .68rem; font-weight: 800; letter-spacing: .06em; color: var(--ad-ink); text-transform: uppercase; }
.corner-toast .toast-body { font-size: .78rem; color: var(--ad-ink); margin-top: .3rem; min-height: 40px; display: flex; align-items: center; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Download interstitial modal */
dialog.dl-modal {
  border: none; border-radius: var(--radius-lg); padding: 0; max-width: 380px; width: calc(100% - 2.4rem);
  box-shadow: var(--shadow-lg);
}
dialog.dl-modal::backdrop { background: rgba(20,10,30,.55); backdrop-filter: blur(2px); }
.dl-modal-inner { padding: 1.5rem; text-align: center; position: relative; }
.dl-modal .toast-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; background: var(--bg-soft); font-size: 1.1rem; }
.dl-modal .ad-slot { min-height: 200px; margin-top: 1rem; }
.dl-modal p.timer { margin-top: 1rem; font-size: .85rem; color: var(--ink-soft); }

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

/* JS-disabled notice */
.no-js-note { display: none; }
.no-js .no-js-note { display: block; padding: 1rem 1.2rem; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); font-size: .9rem; font-weight: 600; text-align: center; margin: 1rem auto; max-width: 760px; }
.no-js .js-only { display: none !important; }
