/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #0f1b2d;
  --muted: #5a6677;
  --line: #dbe1e8;
  --line-strong: #c3ccd6;
  --accent: #16325c;
  --accent-2: #24508f;
  --accent-soft: #e8eef7;
  --ok: #146c43;
  --ok-bg: #e6f4ec;
  --ok-line: #9fd3b6;
  --ko: #b42318;
  --ko-bg: #fdecea;
  --ko-line: #f1aaa4;
  --mid: #8a5a00;
  --mid-bg: #fdf3dc;
  --radius: 14px;
  --radius-sm: 9px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 8px 24px rgba(15, 27, 45, .07);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; color: inherit; }
a { color: var(--accent-2); }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.015em; }
fieldset { border: 0; padding: 0; min-width: 0; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1040px; margin-inline: auto; padding-inline: 16px; }
.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; }
.skip-link { position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: var(--accent); color: #fff; z-index: 9999; border-radius: 8px; }
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Header / footer
   ============================================================= */
.site-header { background: var(--accent); color: #fff; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 44px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: .95rem; letter-spacing: -.01em; }
.brand-mark { width: 20px; height: 20px; }
.header-nav { display: flex; gap: 14px; font-size: .82rem; }
.header-nav a { color: rgba(255,255,255,.85); text-decoration: none; }
.header-nav a:hover { color: #fff; text-decoration: underline; }
.header-nav a:not(:last-child) { display: none; }

.site-footer { background: #0e1f3a; color: rgba(255,255,255,.8); font-size: .85rem; padding: 28px 0 34px; margin-top: 40px; }
.site-footer a { color: #fff; }
.footer-inner { display: grid; gap: 8px; }

/* =============================================================
   5. Hero + tool card
   ============================================================= */
.hero { padding-top: 10px; }
.hero h1 { font-size: 1.14rem; font-weight: 800; color: var(--accent); }
.hero-sub { font-size: .8rem; color: var(--muted); margin: 3px 0 8px; line-height: 1.35; }

.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  max-width: 640px;
}
.noscript { padding: 12px; background: var(--mid-bg); border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 10px; }

/* Segmented controls */
.controls { display: grid; gap: 8px; margin-bottom: 8px; }
.controls-row { display: flex; gap: 8px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  flex: 1 1 0; text-align: center; font-size: .84rem; font-weight: 600; color: var(--muted);
  padding: 7px 6px; border-radius: 7px; cursor: pointer; user-select: none; white-space: nowrap;
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.seg input:checked + label { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(15,27,45,.12); }
.seg input:focus-visible + label { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.seg-cuerpo label { font-size: .9rem; padding: 8px 6px; }
.seg-sexo { flex: 2 1 0; }
.seg-edad { flex: 3 1 0; }
.seg-edad label { padding-inline: 2px; }

/* Test rows */
.tests { display: grid; }
.test { padding: 6px 0 5px; border-top: 1px solid var(--line); }
.test-row { display: grid; grid-template-columns: 1fr auto 52px; align-items: center; gap: 8px; }
.test-name { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.test-input { display: flex; align-items: center; gap: 4px; }
.test-input input {
  width: 72px; height: 38px; padding: 0 8px; text-align: right; font-size: 1.02rem; font-weight: 600;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; font-variant-numeric: tabular-nums;
}
.test-input-time input { width: 48px; text-align: center; }
.test-input input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(36,80,143,.18); }
.test-input input[aria-invalid="true"] { border-color: var(--ko); }
.test-input input::placeholder { color: #a6b0bc; font-weight: 400; font-size: .85rem; }
.suf { font-size: .78rem; color: var(--muted); width: 26px; }
.colon { font-weight: 700; color: var(--muted); }
.test-input-time { margin-right: 30px; }

.badge {
  display: grid; place-items: center; height: 38px; border-radius: 8px; font-weight: 800; font-size: 1.05rem;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.badge.is-apto { font-size: .68rem; letter-spacing: .02em; }
.badge.is-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.is-mid { background: var(--mid-bg); color: var(--mid); border-color: #f0d38f; }
.badge.is-ko { background: var(--ko-bg); color: var(--ko); border-color: var(--ko-line); }
.hint { font-size: .78rem; color: var(--muted); margin-top: 2px; line-height: 1.3; min-height: 1.3em; }
.hint strong { color: var(--ink); font-weight: 600; }
.hint.is-ko { color: var(--ko); }
.hint.is-ok { color: var(--ok); }

/* Result */
.result {
  margin-top: 6px; padding: 11px 14px; border-radius: 11px; border: 2px solid var(--line);
  background: var(--bg); transition: background .2s var(--ease-out), border-color .2s var(--ease-out);
}
.result:focus { outline: none; }
.result-title { font-weight: 800; font-size: 1.12rem; line-height: 1.2; }
.result-detail { font-size: .84rem; margin-top: 2px; line-height: 1.35; color: var(--muted); }
.result[data-state="ok"] { background: var(--ok-bg); border-color: var(--ok); }
.result[data-state="ok"] .result-title, .result[data-state="ok"] .result-detail { color: var(--ok); }
.result[data-state="ko"] { background: var(--ko-bg); border-color: var(--ko); }
.result[data-state="ko"] .result-title, .result[data-state="ko"] .result-detail { color: var(--ko); }
.result[data-state="ok"] .result-title::before { content: "✓ "; }
.result[data-state="ko"] .result-title::before { content: "✕ "; }

.tool-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: .76rem; color: var(--muted); }
.link-btn { color: var(--accent-2); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; padding: 2px 0; font-size: .8rem; }
.disclaimer-inline { font-size: .78rem; color: var(--muted); margin-top: 10px; max-width: 640px; }

/* =============================================================
   6. Content sections
   ============================================================= */
.section { padding-top: 36px; }
.section h2 { font-size: 1.35rem; color: var(--accent); margin-bottom: 12px; }
.section h2:not(:first-child) { margin-top: 30px; }

.steps { list-style: none; padding: 0; display: grid; gap: 12px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.step-num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: .9rem; margin-bottom: 8px; }
.step h3 { font-size: 1.02rem; margin-bottom: 4px; }
.step p { font-size: .92rem; color: var(--muted); }

.two-col { display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { font-size: 1.08rem; margin-bottom: 8px; color: var(--ink); }
.prose p, .prose li { font-size: .94rem; }
.prose p + p, .prose ul + p, .prose p + ul { margin-top: 10px; }
.prose ul { padding-left: 1.2em; display: grid; gap: 6px; }

.source { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.tables { display: grid; gap: 14px; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-weight: 700; padding: 12px 14px 8px; font-size: .95rem; color: var(--ink); }
th, td { padding: 7px 14px; text-align: left; border-top: 1px solid var(--line); white-space: nowrap; }
thead th { background: var(--accent-soft); color: var(--accent); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tbody th { font-weight: 700; }
tbody th small { font-weight: 500; color: var(--ko); }
.row-zero { background: #fff6f5; }
.row-five { background: #f1f8f4; }
.table-wide th[rowspan] { white-space: normal; min-width: 140px; vertical-align: top; }
.table-wide small { display: block; color: var(--muted); font-weight: 500; }
.table-note { font-size: .85rem; color: var(--muted); margin-top: 10px; }

.telegram {
  display: grid; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid #229ed9; border-radius: var(--radius); padding: 18px;
}
.telegram-icon { width: 40px; height: 40px; color: #229ed9; }
.telegram h2 { font-size: 1.15rem; margin-bottom: 4px; }
.telegram p { font-size: .92rem; color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; border-radius: 10px; padding: 11px 18px; text-decoration: none; font-size: .95rem; }
.btn-telegram { background: #229ed9; color: #fff; }
.btn-telegram:hover { background: #1b8bc0; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }

.faq { display: grid; gap: 8px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.faq summary { cursor: pointer; padding: 13px 16px; font-weight: 600; font-size: .95rem; list-style: none; position: relative; padding-right: 40px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 1.3rem; color: var(--accent-2); font-weight: 500; }
.faq details[open] summary::after { content: "–"; }
.faq details p { padding: 0 16px 14px; font-size: .93rem; color: var(--muted); }

.tools-grid { display: grid; gap: 12px; }
.tool-link { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink); }
a.tool-link:hover { border-color: var(--accent-2); }
.tool-link h3 { font-size: 1.02rem; margin: 6px 0 4px; }
.tool-link p { font-size: .9rem; color: var(--muted); }
.tool-link-tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ok); }
.tool-link-soon { border-style: dashed; background: transparent; }
.tool-link-soon .tool-link-tag { color: var(--mid); }

.notice { background: var(--mid-bg); border: 1px solid #f0d38f; border-radius: var(--radius); padding: 18px; }
.notice h2 { font-size: 1.1rem; color: var(--mid); margin-bottom: 6px; }
.notice p { font-size: .92rem; }

/* =============================================================
   7. Ad placeholders
   ============================================================= */
.ad-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1.5px dashed var(--line-strong); border-radius: 10px; background: repeating-linear-gradient(45deg, #f9fafc, #f9fafc 8px, #f1f4f8 8px, #f1f4f8 16px);
  color: #8793a3; text-align: center;
}
.ad-label { font-weight: 800; letter-spacing: .14em; font-size: .85rem; }
.ad-size { font-size: .7rem; }
.ad-leaderboard { min-height: 100px; margin-top: 22px; max-width: 728px; }
.ad-incontent { min-height: 280px; max-width: 336px; margin: 26px auto 4px; }
.ad-rect { width: 300px; max-width: 100%; height: 250px; margin: 10px auto 14px; }
.ad-small { width: 100%; height: 50px; }

.ad-pop { margin: auto; border: 0; padding: 0; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.3); max-width: calc(100vw - 32px); width: 340px; background: var(--surface); color: var(--ink); }
.ad-pop::backdrop { background: rgba(10, 20, 35, .55); }
.ad-pop[open]:not(:modal) { position: fixed; inset: 0; margin: auto; z-index: 1000; }
.ad-pop-inner { position: relative; padding: 18px 20px 20px; text-align: center; }
.ad-pop-title { font-weight: 700; font-size: 1rem; padding-right: 24px; text-align: left; }
.ad-pop-x { position: absolute; top: 8px; right: 10px; width: 34px; height: 34px; border-radius: 50%; font-size: 1.5rem; line-height: 1; color: var(--muted); }
.ad-pop-x:hover { background: var(--bg); color: var(--ink); }
.ad-pop .btn { width: 100%; }

.ad-toast {
  position: fixed; right: 12px; bottom: 12px; z-index: 900; width: min(340px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 8px 34px 8px 8px; animation: toast-in .35s var(--ease-out);
}
.ad-toast-x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; font-size: 1.2rem; color: var(--muted); }
.ad-toast-x:hover { background: var(--bg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (max-width: 359px) {
  .seg label { font-size: .76rem; }
  .test-input input { width: 62px; }
  .test-input-time input { width: 42px; }
  .test-name { font-size: .84rem; }
}
@media (min-width: 540px) {
  .hero h1 { font-size: 1.5rem; }
  .hero-sub { font-size: .92rem; }
  .tool-card { padding: 16px 18px; }
  .test-input input { width: 84px; }
  .test-input-time input { width: 52px; }
  .test-row { grid-template-columns: 1fr auto 60px; }
  .header-nav a:not(:last-child) { display: inline; }
}
@media (min-width: 720px) {
  .hero { padding-top: 28px; }
  .hero h1 { font-size: 1.9rem; max-width: 760px; }
  .hero-sub { margin: 6px 0 16px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; }
  .tools-grid { grid-template-columns: 1fr 1fr; }
  .telegram { grid-template-columns: auto 1fr auto; }
  .ad-leaderboard { min-height: 90px; }
  .section h2 { font-size: 1.55rem; }
}
@media (min-width: 960px) {
  .hero { text-align: center; }
  .hero h1, .hero-sub, .tool-card, .disclaimer-inline { margin-inline: auto; }
  .tool-card { text-align: left; }
  .ad-leaderboard { margin-inline: auto; }
  .tables { grid-template-columns: repeat(3, 1fr); }
  .tables th, .tables td { padding-inline: 10px; font-size: .84rem; }
  .tables thead th { white-space: normal; }
  .tables tbody th small { display: block; font-size: .72rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ad-toast { animation: none; }
}
