:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #d9d9de;
  --accent: #0071e3;
  --accent-text: #ffffff;
  --error: #b42318;
  --ok: #067647;
}
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101012;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --border: #38383a;
    --accent: #2997ff;
    --accent-text: #001a33;
    --error: #ff8a7d;
    --ok: #5fd39a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101012;
  --surface: #1c1c1e;
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --border: #38383a;
  --accent: #2997ff;
  --accent-text: #001a33;
  --error: #ff8a7d;
  --ok: #5fd39a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.6 -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--text);
}
.wrap { max-width: 820px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 52px; gap: 12px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.navs { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.nav-menu { position: relative; }
.nav-menu summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface);
}
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary::after { content: "▾"; color: var(--muted); }
.nav-menu ul {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 10;
  margin: 0;
  padding: 4px;
  list-style: none;
  min-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / .15);
}
.lang-item { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border-radius: 6px; text-decoration: none; color: var(--text); white-space: nowrap; }
a.lang-item:hover { background: var(--bg); }
.lang-item.current { font-weight: 700; }
.flag { width: 24px; height: 16px; border-radius: 2px; box-shadow: 0 0 0 1px rgb(0 0 0 / .15); flex: none; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.4rem); line-height: 1.12; font-weight: 700; letter-spacing: -.022em; margin: 28px 0 10px; }
h2 { font-size: 1.35rem; line-height: 1.25; font-weight: 650; letter-spacing: -.012em; margin: 36px 0 10px; }
.intro { color: var(--muted); margin: 0 0 12px; }
.privacy-badge { font-size: 14px; color: var(--ok); margin: 0 0 20px; }

.tool { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 22px; box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 8px 24px rgb(0 0 0 / .05); }
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 32px 16px;
  text-align: center;
}
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.dropzone p { margin: 0; }
.drop-title { font-weight: 600; }
.drop-or { color: var(--muted); margin: 6px 0 10px !important; }
.btn {
  font: inherit;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s, filter .15s, transform .1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.messages { margin: 12px 0 0; color: var(--error); font-size: 14px; }
.messages:empty { display: none; }
.messages div + div { margin-top: 4px; }
.list-title { margin-top: 20px; font-size: 1rem; }
.file-list { list-style: none; padding: 0; margin: 0 0 14px; }
.file-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
}
.file-info { flex: 1; min-width: 0; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 13px; color: var(--muted); }
.icon-btn {
  font: inherit;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .primary { margin-left: auto; }
#progress-area { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
#progress-area[hidden], #list-area[hidden], #result-area[hidden] { display: none; }
progress { flex: 1; height: 14px; }
.result-text { font-weight: 600; color: var(--ok); }
#result-area { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#result-area .result-text { flex-basis: 100%; margin: 0; }

.content details { border-bottom: 1px solid var(--border); padding: 10px 0; }
.content summary { cursor: pointer; font-weight: 600; }
.content details p { margin: 8px 0 0; color: var(--muted); }
.app-promo {
  margin: 36px 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.promo-cta { font-weight: 600; }
.site-footer { border-top: 1px solid var(--border); padding: 20px 0; font-size: 14px; color: var(--muted); }
.name-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.name-row label { font-size: 14px; color: var(--muted); }
.name-input { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 180px; }
.name-input input {
  font: inherit;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.name-input span { color: var(--muted); }
.footer-links { margin: 0 0 6px; }
.footer-links a { color: var(--muted); }
.email-box { display: inline-flex; gap: 8px; align-items: center; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 1.05rem; }
.email-box span { color: var(--muted); }
.content p { margin: 0 0 12px; }

/* Contador de palabras */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.counter textarea { width: 100%; min-height: 220px; padding: 12px; font: inherit; line-height: 1.5; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; resize: vertical; }
.counter textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.counter-actions { margin: 10px 0 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 0 0 8px; }
.stat { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.stat dt { font-size: 13px; color: var(--muted); }
.stat dd { margin: 2px 0 0; font-size: 1.4rem; font-weight: 700; }
.stats.times .stat dd { font-size: 1.1rem; }
.top-words { margin: 0; padding-left: 22px; }
.top-empty { margin: 0; color: var(--muted); font-size: 14px; }
.related { margin: 28px 0 0; }
.related ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.related a { display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); text-decoration: none; }

/* Comprimir imagen */
.options { margin: 16px 0 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.options legend { padding: 0 6px; font-size: 14px; color: var(--muted); }
.mode-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; }
.radio { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.opt-group label, .opt-row label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.opt-row { display: flex; flex-wrap: wrap; gap: 12px; }
.opt-row > div { flex: 1; min-width: 150px; }
.options select, .options input[type=number] { font: inherit; min-height: 44px; padding: 0 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.options select { width: 100%; }
.options input[type=number] { width: 100%; }
.options input[type=range] { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font: inherit; font-size: 14px; min-height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.img-list .thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); flex: none; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.summary { margin: 0 0 12px; font-weight: 600; color: var(--ok); }
.progress-text { font-size: 14px; color: var(--muted); }

/* Responsividad y navegación */
.bar { flex-wrap: wrap; padding-top: 4px; padding-bottom: 4px; }
.lang-short { display: none; font-weight: 600; }
@media (max-width: 560px) { .lang-long { display: none; } .lang-short { display: inline; } .nav-menu summary { padding: 0 8px; gap: 6px; } }
.nav-menu ul { width: max-content; min-width: 100%; max-width: min(320px, calc(100vw - 32px)); }
.nav-menu ul a, .nav-menu ul span { white-space: normal; overflow-wrap: break-word; }
h1 { font-size: clamp(1.45rem, 7vw, 1.9rem); overflow-wrap: anywhere; hyphens: auto; }
h2, .content p, .content li, .content summary { overflow-wrap: break-word; hyphens: auto; }
.content summary { padding: 12px 0; }
.footer-links a { display: inline-block; padding: 8px 2px; }
.related a { min-height: 40px; display: inline-flex; align-items: center; }
@media (max-width: 560px) {
  .site-header .bar { position: relative; }
  .nav-menu { position: static; }
  .nav-menu ul { left: 16px; right: 16px; top: 100%; width: auto; min-width: 0; max-width: none; }
}

/* Generador de QR */
.qr-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .qr-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 300px); align-items: start; } }
.qr-fields { display: grid; gap: 4px; margin-top: 4px; }
.qr-fields label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.qr-fields label.radio { font-size: 15px; color: var(--text); margin-top: 10px; min-height: 36px; }
.qr-fields input[type=text], .qr-fields input[type=tel], .qr-fields select, .qr-fields textarea { width: 100%; font: inherit; padding: 10px; min-height: 44px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.qr-fields textarea { resize: vertical; line-height: 1.4; }
.qr-fields input:focus, .qr-fields textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.qrtool input[type=color] { width: 100%; height: 44px; padding: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.qr-preview { display: flex; justify-content: center; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.qr-preview canvas { width: 100%; max-width: 276px; height: auto; aspect-ratio: 1; image-rendering: pixelated; }
.qr-out .actions { margin-top: 8px; }
.qr-fields input[type=checkbox] { width: 24px; height: 36px; margin: 0; accent-color: var(--accent); }
.qr-fields[hidden] { display: none; }
.img-list .thumb.ph { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface); }
.mode-col { display: grid; gap: 4px; margin-bottom: 8px; }
.text-input { width: 100%; font: inherit; min-height: 44px; padding: 0 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.text-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#work-area .file-list { margin-bottom: 4px; }
.nav-menu ul { max-height: calc(100vh - 80px); overflow-y: auto; }
.radio.keep { margin-top: 10px; min-height: 36px; }
.radio.keep input[type=checkbox] { width: 24px; height: 36px; margin: 0; accent-color: var(--accent); }

/* Índice de herramientas, menú agrupado y migas de pan */
.menu-head { padding: 8px 12px 4px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.menu-head:not(:first-child) { border-top: 1px solid var(--border); margin-top: 4px; }
.crumbs { margin: 0 0 8px; font-size: 14px; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 0; padding: 0; margin: 0; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin: 0 8px; }
.crumbs a { color: var(--muted); display: inline-block; padding: 8px 0; }
.crumbs [aria-current] { overflow-wrap: anywhere; }
.tool-group { margin: 24px 0 0; }
.tool-group h2 { margin: 0 0 10px; font-size: 1.15rem; }
.tool-cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.tool-cards a { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); text-decoration: none; }
.tool-cards a:hover, .tool-cards a:focus-visible { border-color: var(--accent); }
.tool-cards strong { font-size: 1rem; }
.tool-cards span { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.chip-links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip-links a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 14px; }
.chip-links a:hover, .chip-links a:focus-visible { border-color: var(--accent); }
.tool-group + .content, .tool-group ~ .content { margin-top: 28px; }

/* Herramientas de texto y contraseñas */
.sr-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.texttool textarea { width: 100%; min-height: 200px; padding: 12px; font: inherit; line-height: 1.5; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; resize: vertical; }
.texttool textarea:focus, .pw-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.wrap-actions { flex-wrap: wrap; }
.summary-line { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.pw-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.15rem; letter-spacing: .02em; margin-bottom: 8px; }
.pw-strength { margin: 10px 0 4px; font-size: 14px; color: var(--muted); }
.pw-strength b { color: var(--text); }
#meter { width: 100%; height: 8px; }
.texttool .options label[for=length] { display: block; font-size: 14px; color: var(--muted); margin: 4px 0; }
.texttool input[type=checkbox] { width: 24px; height: 36px; margin: 0; accent-color: var(--accent); }
.texttool .actions .primary { margin-left: 0; }

/* Guías */
.guide-meta { margin: 0 0 16px; font-size: 14px; color: var(--muted); }
.guide-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 18px 0; padding: 14px 16px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; background: var(--surface); }
.guide-cta .btn { margin-left: auto; }
.guide-box { margin: 28px 0 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.guide-box h2 { margin: 0 0 8px; font-size: 1.05rem; }
.guide-box ul { margin: 0; padding-left: 20px; }
.guide-box a { display: inline-block; padding: 6px 0; }
article.content ol, article.content ul { padding-left: 22px; }
article.content li { margin: 6px 0; }
.crumbs li { display: inline-flex; align-items: center; }
.crumbs [aria-current] { padding: 8px 0; }
.drop-hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
[hidden] { display: none !important; }

/* Organizar PDF */
.page-grid { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); }
.pg-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: grab; }
.pg-card.dragging { opacity: .45; }
.pg-card.over { outline: 2px solid var(--accent); outline-offset: 1px; }
.pg-thumb { position: relative; height: 170px; overflow: hidden; border-radius: 6px; background: var(--bg); }
.pg-thumb canvas { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: none; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.pg-card.deleted .pg-thumb { opacity: .3; }
.pg-card.deleted .pg-num { text-decoration: line-through; color: var(--muted); }
.pg-num { font-size: 13px; text-align: center; overflow-wrap: anywhere; }
.pg-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.pg-actions .icon-btn { min-width: 40px; }

/* Pulido visual (estilo sobrio, cercano al de Apple) */
.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 5%, var(--surface)); }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: scale(.98); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.site-header { border-bottom-color: color-mix(in srgb, var(--border) 70%, transparent); }
.brand { letter-spacing: -.01em; }
.nav-menu summary, .icon-btn, .file-list li, .name-input input, .email-box { border-radius: 12px; }
.tool-cards a { border-radius: 14px; padding: 16px; transition: border-color .15s, box-shadow .15s; }
.tool-cards a:hover { box-shadow: 0 6px 18px rgb(0 0 0 / .08); }
.nav-menu ul { border-radius: 14px; box-shadow: 0 10px 34px rgb(0 0 0 / .18); }
.app-promo { border-radius: 16px; }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn:active:not(:disabled) { transform: none; } }

.theme-btn { font: inherit; width: 44px; height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 18px; line-height: 1; }
.theme-btn:hover { background: color-mix(in srgb, var(--text) 5%, var(--surface)); }
@media (max-width: 560px) { .navs { gap: 6px; } }

/* Herramientas nuevas: firmar, recortar, rotar imagen, texto */
.field-label { display: block; font-weight: 600; margin-bottom: 6px; }
.text-out { width: 100%; padding: 12px; font: inherit; line-height: 1.5; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 12px; resize: vertical; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.preview-box { display: flex; justify-content: center; padding: 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 12px; background: repeating-conic-gradient(var(--bg) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.preview-box canvas { max-width: 100%; max-height: 420px; width: auto; height: auto; }
.label-like { display: block; font-size: 14px; color: var(--muted); }
.crop-size { font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.crop-stage { position: relative; display: inline-block; max-width: 100%; margin: 4px 0; touch-action: none; user-select: none; line-height: 0; }
.crop-stage canvas { display: block; border-radius: 4px; }
.crop-box { position: absolute; border: 2px solid #fff; outline: 1px solid rgb(0 0 0 / .55); box-shadow: 0 0 0 9999px rgb(0 0 0 / .45); cursor: move; touch-action: none; }
.crop-box:focus-visible { outline: 3px solid var(--accent); }
.crop-h { position: absolute; width: 22px; height: 22px; background: #fff; border: 2px solid var(--accent); border-radius: 50%; touch-action: none; }
.crop-h::after { content: ""; position: absolute; inset: -12px; }
.crop-h[data-h=nw] { left: -11px; top: -11px; cursor: nwse-resize; } .crop-h[data-h=ne] { right: -11px; top: -11px; cursor: nesw-resize; }
.crop-h[data-h=sw] { left: -11px; bottom: -11px; cursor: nesw-resize; } .crop-h[data-h=se] { right: -11px; bottom: -11px; cursor: nwse-resize; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tab[aria-selected=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.sig-pane { margin-bottom: 10px; }
.sig-pad { display: block; width: 100%; max-width: 560px; aspect-ratio: 3 / 1; margin: 8px 0; background: #fff; border: 1px dashed var(--border); border-radius: 12px; touch-action: none; cursor: crosshair; }
.page-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; }
.page-label { min-width: 120px; text-align: center; font-weight: 600; }
.sign-stage { position: relative; margin: 0 auto 8px; border: 1px solid var(--border); border-radius: 4px; line-height: 0; touch-action: none; user-select: none; }
.sign-stage canvas { display: block; }
.sig-box { position: absolute; border: 1px dashed var(--accent); cursor: move; touch-action: none; }
.sig-box img { width: 100%; height: 100%; display: block; pointer-events: none; }
.sig-handle { position: absolute; right: -11px; bottom: -11px; width: 22px; height: 22px; background: #fff; border: 2px solid var(--accent); border-radius: 50%; cursor: nwse-resize; touch-action: none; }
.sig-handle::after { content: ""; position: absolute; inset: -12px; }
.imgedit select, .signtool select { font: inherit; min-height: 44px; padding: 0 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.imgedit select, .signtool select { width: 100%; }
.imgedit input[type=range], .signtool input[type=range] { width: 100%; }

/* Buscaminas */
.ms-levels { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 12px; }
.ms-levels .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text, #fff); border-color: var(--accent); }
.ms-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 420px; margin: 0 auto 12px; }
.ms-stat { display: flex; flex-direction: column; align-items: center; min-width: 72px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.ms-stat span { font-size: 12px; color: var(--muted); }
.ms-stat b { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.ms-face { font-size: 1.6rem; min-width: 52px; padding: 4px 10px; }
.ms-wrap { overflow-x: auto; display: flex; justify-content: center; padding: 2px; }
.ms-board { display: flex; flex-direction: column; width: max-content; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ms-row { display: flex; }
.ms-cell { box-sizing: border-box; width: var(--cs); height: var(--cs); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: calc(var(--cs) * .55); line-height: 1; cursor: pointer; background: var(--border); border: 1px solid var(--surface); border-radius: 3px; }
.ms-cell:hover { filter: brightness(1.08); }
.ms-cell.open { background: var(--bg); cursor: default; filter: none; }
.ms-cell.mine { background: color-mix(in srgb, var(--error) 30%, var(--bg)); }
.ms-cell.boom { background: var(--error); }
.ms-cell.wrong { background: color-mix(in srgb, var(--error) 30%, var(--border)); text-decoration: line-through; }
.ms-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ms-cell.n1 { color: #2f7de1; } .ms-cell.n2 { color: #2e9e4f; } .ms-cell.n3 { color: #e0443a; } .ms-cell.n4 { color: #7b4fd6; }
.ms-cell.n5 { color: #c2571a; } .ms-cell.n6 { color: #12a5a5; } .ms-cell.n7, .ms-cell.n8 { color: var(--muted); }
.ms-actions { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.ms-actions .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text, #fff); border-color: var(--accent); }
.ms-best { color: var(--muted); }
.ms-msg { text-align: center; color: var(--muted); font-weight: 600; min-height: 1.4em; }
.ms-msg.win { color: var(--ok); }
.ms-hint { text-align: center; font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* Sudoku */
.sd-board { display: flex; flex-direction: column; width: max-content; border: 2px solid var(--text); border-radius: 6px; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.sd-row { display: flex; }
.sd-cell { box-sizing: border-box; width: var(--cs); height: var(--cs); display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); font-size: calc(var(--cs) * .56); line-height: 1; cursor: pointer; background: var(--bg); color: var(--accent); }
.sd-cell.bl { border-left: 2px solid var(--text); }
.sd-cell.bt { border-top: 2px solid var(--text); }
.sd-cell.given { color: var(--text); font-weight: 700; }
.sd-cell.peer { background: color-mix(in srgb, var(--accent) 9%, var(--bg)); }
.sd-cell.same { background: color-mix(in srgb, var(--accent) 24%, var(--bg)); }
.sd-cell.sel { background: color-mix(in srgb, var(--accent) 38%, var(--bg)); }
.sd-cell.conflict { color: var(--error); }
.sd-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sd-notes { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 100%; height: 100%; font-size: calc(var(--cs) * .25); color: var(--muted); font-weight: 400; text-align: center; }
.sd-notes span { display: flex; align-items: center; justify-content: center; }
.sd-pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin: 12px auto 0; }
.sd-digit { min-height: 44px; padding: 0; font-size: 1.15rem; font-weight: 700; }
.sd-digit:disabled { opacity: .3; }
.sudoku .ms-actions .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text, #fff); border-color: var(--accent); }

/* 2048 */
.g-wrap { display: flex; justify-content: center; }
.g-board { position: relative; width: min(100%, 440px); aspect-ratio: 1; container-type: inline-size; background: var(--border); border-radius: 12px; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; }
.g-board:focus-visible { box-shadow: 0 0 0 3px var(--accent); }
.g-bg { position: absolute; inset: 0; }
.g-bg i { position: absolute; width: 21.25%; height: 21.25%; left: calc(3% + var(--c) * 24.25%); top: calc(3% + var(--r) * 24.25%); background: color-mix(in srgb, var(--bg) 55%, transparent); border-radius: 8px; }
.g-tiles { position: absolute; inset: 0; }
.g-tile { position: absolute; width: 21.25%; height: 21.25%; left: calc(3% + var(--c) * 24.25%); top: calc(3% + var(--r) * 24.25%); display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--surface); color: var(--text); font-weight: 800; font-size: 9cqw; transition: left 110ms ease, top 110ms ease; box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.g-tile.big { font-size: 7cqw; }
.g-tile[data-v="2"] { background: color-mix(in srgb, var(--text) 12%, var(--surface)); }
.g-tile[data-v="4"] { background: color-mix(in srgb, var(--accent) 26%, var(--surface)); }
.g-tile.new { animation: g-new 160ms ease-out; }
.g-tile.pop { animation: g-pop 160ms ease-out; z-index: 2; }
@keyframes g-new { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes g-pop { 50% { transform: scale(1.15); } }
.g-over { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 16px; border-radius: 12px; background: color-mix(in srgb, var(--bg) 82%, transparent); font-weight: 700; font-size: 1.15rem; }
.g-over[hidden] { display: none; }
.g-over p { margin: 0; }
@media (prefers-reduced-motion: reduce) { .g-tile { transition: none; } .g-tile.new, .g-tile.pop { animation: none; } }

/* Aviso en línea de los juegos */
.g-confirm { display: flex; align-items: center; justify-content: center; gap: 8px 16px; flex-wrap: wrap; margin: 12px 0 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); text-align: center; }
.g-confirm[hidden] { display: none; }
.g-confirm p { margin: 0; font-weight: 600; }

/* Calculadoras y conversores */
.calc-modes { justify-content: flex-start; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px 16px; margin-bottom: 12px; }
.calc-field label { display: block; font-size: 14px; color: var(--muted); margin: 0 0 4px; }
.calc-field small { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.calc-field select.text-input { padding-right: 6px; }
.calc-input { position: relative; display: flex; align-items: center; }
.calc-input .text-input { padding-right: 44px; }
.calc-suffix { position: absolute; right: 12px; color: var(--muted); pointer-events: none; font-size: 14px; }
.calc-check { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 15px; }
.calc-check input { width: 24px; height: 36px; margin: 0; accent-color: var(--accent); }
.calc-out { margin-top: 8px; }
.calc-stats .stat.main { grid-column: 1 / -1; border-color: var(--accent); }
.calc-stats .stat.main dd { font-size: 1.9rem; color: var(--accent); }
.calc-stats .stat dd { overflow-wrap: anywhere; }
.calc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.calc-steps { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.calc-steps summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }
.calc-steps #calc-steps-body { color: var(--muted); font-size: 15px; line-height: 1.7; }
.calc-steps #calc-steps-body p { margin: 4px 0; overflow-wrap: anywhere; }
.calc-scroll { overflow: auto; max-height: 420px; border: 1px solid var(--border); border-radius: 10px; margin-top: 10px; }
.calc-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.calc-table th, .calc-table td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.calc-table th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 600; }
.calc-table td:first-child, .calc-table th:first-child { text-align: left; }
.calc-chart { width: 100%; height: auto; margin-top: 10px; }
.calc-chart .c-a { fill: var(--accent); }
.calc-chart .c-b { fill: color-mix(in srgb, var(--accent) 35%, var(--surface)); }
.calc-chart text { fill: var(--muted); font-size: 11px; }
.calc-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 4px; }
.calc-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.calc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.calc-chips .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text, #fff); border-color: var(--accent); }
.calc-sec { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.calc-sec h3 { margin: 0 0 8px; font-size: 1.05rem; }
.calc-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.calc-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); overflow-wrap: anywhere; }
.calc-list .btn { flex: none; }
.calc-err { color: #c0392b; font-size: 14px; margin: 4px 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .calc-err { color: #ff8a80; } }
:root[data-theme="dark"] .calc-err { color: #ff8a80; }
.sx-print { display: none; }
.split .calc-list li small { color: var(--muted); }
@media print {
  body.sx-printing .site-header, body.sx-printing .site-footer, body.sx-printing main > :not(#tool) { display: none !important; }
  body.sx-printing #tool { border: 0; box-shadow: none; padding: 0; background: #fff; color: #000; }
  body.sx-printing #tool > :not(#sx-print-area) { display: none !important; }
  body.sx-printing #sx-print-area { display: block; }
  body.sx-printing .calc-table th, body.sx-printing .calc-table td { color: #000; border-color: #999; }
}

/* Conecta 4 */
.c4-board { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; width: min(100%, 440px); padding: 8px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 70%, #000); touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.c4-col { display: grid; grid-template-rows: repeat(6, 1fr); gap: 6px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 999px; min-height: 0; font: inherit; color: inherit; }
.c4-col:disabled { cursor: default; }
.c4-col:not(:disabled):hover { background: rgb(255 255 255 / .12); }
.c4-col:focus-visible { outline: 3px solid #fff; outline-offset: 1px; }
.c4-cell { display: block; aspect-ratio: 1; border-radius: 50%; background: var(--bg); box-shadow: inset 0 3px 6px rgb(0 0 0 / .35); position: relative; }
.c4-cell.p1, .c4-cell.p2 { box-shadow: inset 0 -3px 5px rgb(0 0 0 / .25), inset 0 2px 3px rgb(255 255 255 / .3); }
.c4-cell.p1 { background: #e0443e; }
.c4-cell.p2 { background: #f2c230; }
.c4-cell.p1::after, .c4-cell.p2::after { content: ""; position: absolute; inset: 24%; border-radius: 50%; }
.c4-cell.p1::after { background: rgb(255 255 255 / .35); }
.c4-cell.p2::after { border: 3px solid rgb(0 0 0 / .35); }
.c4-cell.win { outline: 4px solid #fff; outline-offset: -2px; animation: c4-pulse .8s ease-in-out infinite alternate; }
.c4-cell.drop { animation: c4-drop 380ms cubic-bezier(.3, 0, .6, 1) both; }
.c4-cell.win.drop { animation: c4-pulse .8s ease-in-out infinite alternate; }
@keyframes c4-drop { from { transform: translateY(calc(var(--fall, 1) * -105%)); } to { transform: none; } }
@keyframes c4-pulse { from { filter: brightness(1); } to { filter: brightness(1.35); } }
.c4-score { max-width: 360px; }
@media (prefers-reduced-motion: reduce) { .c4-cell.drop, .c4-cell.win { animation: none; } }

/* Nonogramas */
.ng-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.ng-board { --rw: calc(var(--kr, 3) * max(17px, calc(var(--cs, 24px) * .66)) + 8px); --ch: calc(var(--kc, 3) * max(14.5px, calc(var(--cs, 24px) * .72)) + 8px); display: grid; grid-template-columns: var(--rw) repeat(var(--n, 5), var(--cs, 24px)); grid-template-rows: var(--ch) repeat(var(--n, 5), var(--cs, 24px)); width: max-content; margin: 0 auto; user-select: none; -webkit-user-select: none; }
.ng-clue { display: flex; font-size: max(10px, calc(var(--cs, 24px) * .5)); line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.ng-clue i { font-style: normal; font-weight: 600; }
.ng-rcl { justify-content: flex-end; align-items: center; gap: .55em; padding-right: 6px; }
.ng-ccl { flex-direction: column; justify-content: flex-end; align-items: center; gap: .45em; padding-bottom: 5px; }
.ng-clue.done { opacity: .3; }
.ng-clue.sep.ng-rcl { margin-bottom: 0; }
.ng-cell { box-sizing: border-box; border: 1px solid var(--border); background: var(--bg); cursor: pointer; touch-action: none; position: relative; }
.ng-cell.vr { border-right: 2px solid var(--muted); }
.ng-cell.hb { border-bottom: 2px solid var(--muted); }
.ng-cell.on { background: var(--text); }
.ng-cell.x::after { content: "✕"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: calc(var(--cs, 24px) * .6); line-height: 1; }
.ng-cell.done.on { background: var(--accent); border-color: var(--accent); }
.ng-cell:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
.nonogram .ms-actions .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text, #fff); border-color: var(--accent); }

/* Ahorcado */
.hm-cat { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.hm-cat label { font-size: 14px; color: var(--muted); }
.hm-cat select { width: auto; min-width: 180px; }
.hm-fig { display: block; width: min(60%, 200px); height: auto; margin: 4px auto; fill: none; stroke: var(--text); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.hm-man * { stroke: var(--error); }
.hm-clue { text-align: center; color: var(--muted); margin: 4px 0 8px; font-size: 15px; }
.hm-word { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 6px 0 14px; }
.hm-slot { min-width: 1.5em; height: 1.9em; padding: 0 2px; border-bottom: 3px solid var(--text); text-align: center; font-size: clamp(1.2rem, 6vw, 1.8rem); font-weight: 800; line-height: 1.9; }
.hm-slot.miss { color: var(--error); }
.hm-kb { display: grid; grid-template-columns: repeat(auto-fit, minmax(38px, 1fr)); gap: 6px; max-width: 480px; margin: 0 auto; }
.hm-key { min-height: 44px; padding: 0; font-weight: 700; }
.hm-key.ok { background: color-mix(in srgb, var(--ok) 22%, var(--surface)); border-color: var(--ok); }
.hm-key.bad { background: color-mix(in srgb, var(--error) 14%, var(--surface)); border-color: var(--error); color: var(--muted); }
.hm-key:disabled { opacity: .55; }

/* Sopa de letras */
.ws-board { --cs: min(34px, calc((100cqw - 4px) / var(--n, 8))); display: grid; gap: 0; width: max-content; max-width: 100%; margin: 0 auto; border: 2px solid var(--text); border-radius: 6px; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; container-type: normal; }
.ws-row { display: flex; }
.ws-cell { box-sizing: border-box; width: var(--wcs, 34px); height: var(--wcs, 34px); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: calc(var(--wcs, 34px) * .52); line-height: 1; border: 1px solid var(--border); background: var(--bg); cursor: pointer; }
.ws-cell.sel { background: color-mix(in srgb, var(--accent) 40%, var(--bg)); }
.ws-cell.anchor { outline: 3px solid var(--accent); outline-offset: -3px; }
.ws-cell.hint { animation: ws-hint .6s ease-in-out 4 alternate; }
.ws-cell:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
.ws-cell.found.f0 { background: color-mix(in srgb, #e0443e 35%, var(--bg)); }
.ws-cell.found.f1 { background: color-mix(in srgb, #2e9e5b 35%, var(--bg)); }
.ws-cell.found.f2 { background: color-mix(in srgb, #f2c230 45%, var(--bg)); }
.ws-cell.found.f3 { background: color-mix(in srgb, #8e5fd1 35%, var(--bg)); }
.ws-cell.found.f4 { background: color-mix(in srgb, #1f9fd8 35%, var(--bg)); }
.ws-cell.found.f5 { background: color-mix(in srgb, #e0832e 40%, var(--bg)); }
.ws-words { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; }
.ws-words li { padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); font-weight: 600; font-size: 14px; }
.ws-words li.done { text-decoration: line-through; opacity: .5; }
@keyframes ws-hint { from { background: var(--bg); } to { background: color-mix(in srgb, var(--accent) 55%, var(--bg)); } }
@media (prefers-reduced-motion: reduce) { .ws-cell.hint { animation: none; background: color-mix(in srgb, var(--accent) 55%, var(--bg)); } }
