/* ============ Utilia — estilos base ============ */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1f2333;
  --muted: #646b80;
  --border: #e3e6ef;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef0ff;
  --accent: #ec4899;
  --ok: #16a34a;
  --warn: #ca8a04;
  --bad: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --surface: #181c2e;
    --text: #e8eaf3;
    --muted: #9aa1b8;
    --border: #2a2f45;
    --primary: #818cf8;
    --primary-600: #6366f1;
    --primary-50: #22264a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
img, svg, canvas { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: .4em 0 .3em; }
h2 { font-size: 1.3rem; margin: 1.6em 0 .6em; }
h3 { font-size: 1.05rem; margin: 1.2em 0 .4em; }

.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* ---------- Cabecera ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.25rem; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: #fff;
  background: linear-gradient(135deg, #6366f1, #ec4899); font-size: 1.05rem;
}
.site-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.site-nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: .95rem; font-weight: 500; }
.site-nav a:hover { background: var(--primary-50); color: var(--primary); text-decoration: none; }
.site-nav a.nav-hl { color: var(--primary); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 8px; font-size: 1.2rem; padding: 4px 10px; color: var(--text); cursor: pointer; }

@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .site-nav { display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 16px; }
  .site-nav.open { display: flex; }
}

/* ---------- Pie ---------- */
.site-footer { margin-top: 48px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 24px 16px; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Publicidad ---------- */
.ad-slot { margin: 20px 0; min-height: 90px; text-align: center; overflow: hidden; }
.ad-placeholder {
  display: grid; place-items: center; border: 2px dashed var(--border); border-radius: var(--radius);
  color: var(--muted); font-size: .8rem; letter-spacing: .05em; text-transform: uppercase;
}

/* ---------- Migas ---------- */
.breadcrumb { font-size: .85rem; color: var(--muted); margin-top: 16px; }
.breadcrumb a { color: var(--muted); }

/* ---------- Portada ---------- */
.hero { text-align: center; padding: 36px 0 8px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin-bottom: .2em; }
.hero p { color: var(--muted); font-size: 1.1rem; margin: 0 auto 20px; max-width: 600px; }
.search-box { max-width: 520px; margin: 0 auto; position: relative; }
.search-box input { padding-left: 44px; font-size: 1.05rem; height: 52px; border-radius: 26px; }
.search-box::before { content: "🔍"; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 1rem; }
.no-results { text-align: center; color: var(--muted); display: none; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tool-link {
  display: flex; gap: 12px; align-items: center; padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); transition: transform .12s, border-color .12s, box-shadow .12s;
}
.tool-link:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow); }
.tool-icon { font-size: 1.6rem; flex: 0 0 auto; width: 44px; height: 44px; display: grid; place-items: center; background: var(--primary-50); border-radius: 12px; }
.tool-text { display: flex; flex-direction: column; min-width: 0; }
.tool-text small { color: var(--muted); font-size: .85rem; line-height: 1.35; }

/* ---------- Herramienta ---------- */
.lead { color: var(--muted); font-size: 1.05rem; margin-top: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, label.lbl { font-weight: 600; font-size: .9rem; }
.field small { color: var(--muted); font-size: .8rem; }

input[type="text"], input[type="number"], input[type="date"], input[type="search"], input[type="url"], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 18px; height: 18px; }
input[type="color"] { width: 100%; height: 42px; padding: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }

.checks { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.checks label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; font: inherit; font-weight: 600;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer; background: var(--primary); color: #fff; transition: background .12s, transform .06s;
}
.btn:hover { background: var(--primary-600); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--primary-50); color: var(--primary); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.result {
  margin-top: 18px; padding: 18px; border-radius: var(--radius); background: var(--primary-50);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
}
.result-big { font-size: clamp(1.6rem, 5vw, 2.2rem); font-weight: 800; color: var(--primary); line-height: 1.2; word-break: break-word; }
.result-label { color: var(--muted); font-size: .9rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 14px; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.4rem; color: var(--primary); line-height: 1.2; word-break: break-word; }
.stat span { font-size: .8rem; color: var(--muted); }

.table-wrap { overflow-x: auto; margin-top: 14px; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface); font-weight: 600; }
th:first-child, td:first-child { text-align: left; }

.output-mono { font-family: var(--mono); font-size: 1.25rem; word-break: break-all; padding: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.meter { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; width: 0; transition: width .25s, background .25s; }

/* ---------- Texto explicativo (SEO) ---------- */
.content { margin-top: 32px; }
.content p, .content li { color: var(--text); }
.content details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 8px 0; }
.content summary { cursor: pointer; font-weight: 600; }
.content details p { margin: .6em 0 0; color: var(--muted); }

/* ---------- Relacionadas ---------- */
.related { margin-top: 40px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #111827; color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: .95rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- Juego: Palabra del día ---------- */
#wordle { --w-ok: #16a34a; --w-mid: #ca8a04; --w-no: #6b7280; max-width: 500px; margin: 0 auto; position: relative; }
.w-board { display: grid; gap: 6px; width: min(330px, 100%); margin: 8px auto 0; }
.w-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.w-tile {
  aspect-ratio: 1; display: grid; place-items: center; font-size: 1.9rem; font-weight: 800; text-transform: uppercase;
  border: 2px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); user-select: none;
}
.w-tile.filled { border-color: var(--muted); animation: pop .1s; }
.w-tile.revealed { color: #fff; border-color: transparent; animation: flip .5s; }
.w-tile.correct { background: var(--w-ok, #16a34a); color: #fff; border-color: transparent; }
.w-tile.present { background: var(--w-mid, #ca8a04); color: #fff; border-color: transparent; }
.w-tile.absent { background: var(--w-no, #6b7280); color: #fff; border-color: transparent; }
.w-example { width: 230px; margin: 8px 0; }
.w-example .w-tile { font-size: 1.3rem; }
.w-row.shake { animation: shake .4s; }
.w-row.win .w-tile { animation: bounce .6s; }
.w-row.win .w-tile:nth-child(2) { animation-delay: .08s; }
.w-row.win .w-tile:nth-child(3) { animation-delay: .16s; }
.w-row.win .w-tile:nth-child(4) { animation-delay: .24s; }
.w-row.win .w-tile:nth-child(5) { animation-delay: .32s; }

.w-msg {
  position: absolute; top: 40px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 8px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 5; white-space: nowrap;
}
.w-msg.show { opacity: 1; }

.w-keyboard { margin: 18px auto 0; display: grid; gap: 6px; user-select: none; }
.w-krow { display: flex; gap: 5px; justify-content: center; }
.w-key {
  flex: 1; max-width: 44px; height: 54px; border: 0; border-radius: 6px; background: var(--border); color: var(--text);
  font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; text-transform: uppercase; padding: 0; touch-action: manipulation;
}
.w-key.wide { max-width: 70px; flex: 1.5; font-size: .75rem; }
.w-key:active { filter: brightness(.9); }
.w-key.correct { background: var(--w-ok); color: #fff; }
.w-key.present { background: var(--w-mid); color: #fff; }
.w-key.absent { background: var(--w-no); color: #fff; opacity: .55; }

.w-dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 24px; width: min(440px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.w-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.w-dist { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: .9rem; }
.w-dist span { width: 12px; }
.w-dist i { display: block; background: var(--w-no, #6b7280); color: #fff; text-align: right; padding: 1px 8px; font-style: normal; font-weight: 700; border-radius: 3px; }

@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes bounce { 30% { transform: translateY(-14px); } 60% { transform: translateY(2px); } }
@media (prefers-reduced-motion: reduce) { .w-tile, .w-row { animation: none !important; } }
