[hidden] { display: none !important; }

/* =========================================================
   Fuentes locales (public/fonts, licencia OFL en LICENSE.txt).
   Subconjuntos latin y latin-ext de Fontsource; font-display: swap.
   ========================================================= */
@font-face { font-family: 'Press Start 2P'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/press-start-2p-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Press Start 2P'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/press-start-2p-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/space-grotesk-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/space-grotesk-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* =========================================================
   Tokens: arcade sólido y cálido
   Una sola definición por token: light-dark() resuelve el modo
   según color-scheme, que controla data-theme (claro/oscuro/sistema).
   ========================================================= */
:root {
  color-scheme: light dark;
  --bg: light-dark(#fff3e6, #1d120c);
  --surface: light-dark(#fffaf5, #2a1b13);
  --ink: light-dark(#2d1a10, #fff0e2);
  --muted: light-dark(#6f5443, #c4a089);
  --line: light-dark(#f1d9c3, #3d2a1e);
  --line-strong: light-dark(#e4c2a5, #553a29);
  --chip: light-dark(#fff0e1, #352218);
  --shadow-c: light-dark(#2d1a10, #000000);
  --grid-dot: light-dark(rgba(45, 26, 16, .07), rgba(255, 240, 226, .05));
  --accent: #ff6a3d;
  /* Texto sobre fondo naranja: oscuro fijo en ambos temas (el blanco da 2.9:1). */
  --on-accent: #2d1a10;
  /* Texto naranja sobre superficies: en claro hace falta un naranja más oscuro. */
  --accent-text: light-dark(#b23a14, #ff6a3d);
  --gold: #ffb52e;
  --gold-ink: #3a2208;
  --ok: light-dark(#126b42, #3ecf8e);
  --bad: light-dark(#c0283f, #ff7d8c);
  --qr-paper: #fffaf3;

  /* Formas: 3 radios */
  --r-sm: 4px;
  --r-md: 10px;
  --r-pill: 999px;
  /* Sombra dura escalonada, sin desenfoque */
  --shadow: 4px 4px 0 var(--shadow-c);
  --shadow-sm: 2px 2px 0 var(--shadow-c);
  /* Tipografía: 5 tamaños, mínimo 11px */
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 32px;
  --pixel: 'Press Start 2P', monospace;
  --body: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--bg); }
body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--grid-dot) 1.5px, transparent 1.5px);
  background-size: 16px 16px;
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--fs-md);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); }
/* Iconos del sprite (public/icons.svg): un tamaño fijo, así el trazo de 2px se ve igual en todas partes. */
.i { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
/* Foco visible solo con teclado: contorno de tinta, contraste alto en ambos temas. */
:where(button, a, summary, [role="tab"], [role="radio"]):focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.swatch.custom:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---------- Cabecera ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 688px; width: calc(100% - 32px); margin: 16px auto 0; padding: 10px 12px 10px 16px; background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r-md); box-shadow: var(--shadow); }
.logo { font-family: var(--pixel); font-size: var(--fs-sm); text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.logo b { color: var(--accent-text); font-weight: normal; }
.logo-mark { width: 22px; height: 22px; border-radius: var(--r-sm); background: var(--accent); border: 2px solid var(--ink); box-shadow: inset -4px -4px 0 rgba(0, 0, 0, .18); }
.top-actions { display: flex; gap: 8px; align-items: center; }
/* Espacio reservado: el contenido llega tras /api/me y no debe desplazar la cabecera. */
#userBox { display: flex; gap: 8px; align-items: center; justify-content: flex-end; min-width: 112px; min-height: 36px; }
.user-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; display: grid; gap: 16px; }

.hero { padding: 8px 0 4px; }
.hero h1 { font-size: var(--fs-xl); line-height: 1.1; margin: 0 0 8px; letter-spacing: -.02em; }
.hero h1 span { color: var(--accent-text); }
.hero p { margin: 0; color: var(--muted); max-width: 52ch; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 18px; display: grid; gap: 14px; position: relative; }

/* ---------- Pestañas ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--chip); border: 2px solid var(--ink); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 6px; }
.tab { border: 2px solid transparent; background: transparent; border-radius: var(--r-sm); padding: 10px 12px; text-align: left; display: grid; gap: 2px; color: var(--muted); transition: background .2s, color .2s, transform .1s; }
.tab-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: var(--fs-md); color: var(--ink); }
.tab-sub { font-size: var(--fs-sm); }
.tab.active { background: var(--surface); border-color: var(--ink); box-shadow: var(--shadow-sm); }
.tab.active .tab-title { color: var(--accent-text); }

/* ---------- Chips ---------- */
.kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.kind, .chip { background: var(--chip); border: 2px solid var(--line-strong); border-radius: var(--r-pill); padding: 6px 12px; font-size: var(--fs-sm); font-weight: 600; text-decoration: none; color: var(--ink); transition: background .15s, border-color .15s, transform .1s; display: inline-flex; align-items: center; gap: 6px; }
.kind:hover, .chip:hover { border-color: var(--ink); }
.kind.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip-accent { background: var(--chip); border-color: var(--accent); color: var(--accent-text); }
.chip-accent.on { background: var(--accent); border-color: var(--ink); color: var(--on-accent); }
.kind:active, .chip:active, .tab:active, .theme:active { transform: translate(1px, 1px); }

/* ---------- Campos ---------- */
.f { display: grid; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input, textarea { font-family: inherit; line-height: inherit; background: var(--bg); border: 2px solid var(--line-strong); border-radius: var(--r-sm); padding: 10px 12px; font-size: var(--fs-md); color: var(--ink); width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: var(--shadow-sm); }
input[type="color"] { padding: 4px; height: 46px; }
.slug-row { display: flex; align-items: stretch; border: 2px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg); overflow: hidden; }
.slug-row:focus-within { border-color: var(--ink); box-shadow: var(--shadow-sm); }
.slug-row input { border: 0; border-radius: 0; box-shadow: none; min-width: 0; background: transparent; }
.slug-row input:focus { box-shadow: none; }
.prefix { padding: 10px 0 10px 12px; color: var(--muted); white-space: nowrap; font-weight: 600; display: flex; align-items: center; }
.dice { border: 0; border-left: 2px solid var(--line-strong); background: var(--chip); padding: 0 14px; display: grid; place-items: center; }
.dice.roll { animation: roll .45s cubic-bezier(.3, 1.6, .6, 1); }
@keyframes roll { from { transform: rotate(0) scale(.8); } to { transform: rotate(360deg) scale(1); } }

/* ---------- Botones ---------- */
.btn-primary, .btn-secondary { display: inline-block; text-decoration: none; font-family: var(--pixel); font-size: var(--fs-xs); letter-spacing: .5px; padding: 16px; border-radius: var(--r-md); border: 2px solid var(--ink); box-shadow: var(--shadow); transition: transform .08s, box-shadow .08s, filter .15s; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active, .btn-secondary:active { transform: translate(4px, 4px); box-shadow: none; }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-secondary { background: var(--chip); color: var(--ink); }
.btn-ghost { white-space: nowrap; background: var(--chip); border: 2px solid var(--ink); border-radius: var(--r-sm); padding: 6px 10px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.icon-btn { background: var(--chip); border: 2px solid var(--ink); border-radius: var(--r-sm); width: 36px; height: 36px; font-size: var(--fs-md); display: grid; place-items: center; padding: 0; }

.hint { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.link-btn { background: none; border: 0; padding: 4px 0; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--accent-text); }
.msg { margin: 0; font-size: var(--fs-sm); font-weight: 600; }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--ok); }
/* Vacíos no ocupan fila en el grid; el mensaje sigue en el árbol de accesibilidad como región viva. */
#turnstile:empty { display: none; }
.msg:empty { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---------- Resultado ---------- */
.result { text-align: center; justify-items: center; overflow: hidden; border-color: var(--accent); box-shadow: 4px 4px 0 var(--accent); }
.result-badge { display: inline-flex; align-items: center; gap: 8px; font-family: var(--pixel); font-size: var(--fs-xs); color: var(--on-accent); background: var(--accent); border: 2px solid var(--ink); padding: 8px 12px; border-radius: var(--r-pill); }
.short-link { width: 100%; border: 2px dashed var(--accent); background: var(--bg); border-radius: var(--r-md); padding: 16px; display: grid; gap: 6px; transition: background .25s, border-color .25s, transform .1s; }
.short-link:hover { border-style: solid; }
.short-link:active { transform: translate(1px, 1px); }
.short-text { font-size: var(--fs-lg); font-weight: 700; color: var(--ink); word-break: break-all; }
.short-hint { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.short-link.copied { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border-color: var(--ok); border-style: solid; }
.short-link.copied .short-hint { color: var(--ok); font-weight: 700; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.result.fresh { animation: pop .45s steps(4); }
.result.fresh .short-link { animation: blink-border 1.2s steps(2) 2; }
.result.fresh .result-badge { animation: badge .6s steps(2) 2; }
@keyframes pop { 0% { transform: scale(.94); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes blink-border { 50% { border-color: var(--gold); border-style: solid; } }
@keyframes badge { 50% { background: var(--gold); color: var(--gold-ink); } }

.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: 34px; left: 50%; width: 8px; height: 8px; animation: burst .9s steps(8) forwards; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }

/* ---------- QR ---------- */
.qr-card { justify-items: center; }
/* El QR necesita fondo opaco y claro en ambos temas para que los lectores lo distingan. */
.qr-stage { width: min(100%, 380px); aspect-ratio: 1; background: var(--qr-paper); border: 2px solid var(--ink); border-radius: var(--r-md); padding: 14px; box-shadow: var(--shadow-sm); }
#qr { width: 100%; height: 100%; image-rendering: pixelated; display: block; border-radius: var(--r-sm); }
.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.theme { background: var(--chip); border: 2px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 4px; font-size: var(--fs-sm); font-weight: 600; }
.theme.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.palette { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border: 3px solid var(--surface); border-radius: var(--r-pill); padding: 0; box-shadow: 0 0 0 2px var(--line-strong); }
.swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.swatch.custom { position: relative; background: conic-gradient(#ff3d6e, #ffb52e, #7bd389, #3da5ff, #a35cff, #ff3d6e); }
.swatch.custom input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }

/* ---------- Marca ---------- */
.brand-panel h2, .dialog h2 { display: flex; align-items: center; gap: 8px; font-family: var(--pixel); font-size: var(--fs-sm); margin: 0; line-height: 1.6; }
.brand-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.coin { font-family: var(--pixel); font-size: var(--fs-xs); background: var(--gold); color: var(--gold-ink); padding: 7px 9px; border: 2px solid var(--ink); border-radius: var(--r-sm); box-shadow: var(--shadow-sm); }
.lead { margin: 0; }
.preview { margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--bg); border: 2px dashed var(--line-strong); word-break: break-all; }
.preview .host { color: var(--muted); }
.preview mark { background: var(--gold); color: var(--gold-ink); font-weight: 700; padding: 1px 4px; border-radius: var(--r-sm); transition: background .3s; }
.preview mark.flash { animation: flash .5s steps(3); }
@keyframes flash { 0% { background: var(--accent); color: var(--on-accent); } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .full { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: center; font-size: var(--fs-sm); color: var(--ink); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.links { display: grid; gap: 8px; }
.link-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; border: 2px solid var(--line-strong); border-radius: var(--r-md); padding: 12px 14px; background: var(--bg); }
.link-row .path { display: flex; align-items: center; gap: 6px; font-weight: 700; word-break: break-all; }
.link-row .dest { font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; grid-column: 1 / -1; }
.link-row .score { font-family: var(--pixel); font-size: var(--fs-xs); color: var(--accent-text); }
.link-row .acts { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 1 / -1; margin-top: 4px; }
.empty { color: var(--muted); text-align: center; padding: 12px; margin: 0; }
details { border-top: 2px dashed var(--line-strong); padding-top: 10px; }
details summary { cursor: pointer; font-weight: 600; font-size: var(--fs-sm); padding: 4px 0; }
details summary .i { margin-right: 4px; }
details[open] summary { margin-bottom: 10px; }

/* ---------- Diálogos ---------- */
.dialog { border: 2px solid var(--ink); border-radius: var(--r-md); box-shadow: var(--shadow); background: var(--surface); color: var(--ink); width: min(420px, calc(100vw - 32px)); padding: 22px; }
.dialog::backdrop { background: rgba(45, 20, 8, .55); }
.dialog > * + * { margin-top: 12px; }
#authForm { display: grid; gap: 12px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.close-row { display: flex; justify-content: flex-end; margin: -8px -8px 0 0 !important; float: right; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--chip); border: 2px solid var(--line-strong); border-radius: var(--r-sm); padding: 4px; gap: 4px; }
.seg-btn { border: 2px solid transparent; background: transparent; border-radius: var(--r-sm); padding: 8px; font-weight: 600; color: var(--muted); }
.seg-btn.active { background: var(--surface); border-color: var(--ink); color: var(--ink); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: var(--fs-sm); }
.or::before, .or::after { content: ""; flex: 1; height: 2px; background: var(--line-strong); }
#googleBtn { width: 100%; font-family: var(--body); font-size: var(--fs-md); font-weight: 600; letter-spacing: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface); font-weight: 600; font-size: var(--fs-sm); padding: 12px 18px; border: 2px solid var(--ink); border-radius: var(--r-pill); z-index: 10; box-shadow: var(--shadow-sm); animation: toast .25s steps(3); }
@keyframes toast { from { transform: translate(-50%, 12px); opacity: 0; } }
.foot { text-align: center; color: var(--muted); font-size: var(--fs-sm); padding: 0 16px 28px; }

/* ---------- Páginas sueltas: puente de marca y 404 ---------- */
.solo { display: grid; place-items: center; padding: 16px; }
.solo-card { width: min(440px, 100%); text-align: center; justify-items: center; padding: 32px 24px; }
.solo-card h1 { font-family: var(--pixel); font-size: var(--fs-lg); line-height: 1.5; margin: 0; }
.solo-card p { margin: 0; }
.solo-card .dots::after { content: "..."; animation: dots 1s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } }

/* ---------- Ajustes por tamaño y preferencias ---------- */
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .themes { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .top { width: calc(100% - 24px); padding: 8px; gap: 6px; }
  .logo { font-size: var(--fs-xs); gap: 8px; }
  .user-name { display: none; }
}
/* Objetivos táctiles de al menos 44x44px en móvil. Los botones de icono y las muestras de color
   mantienen su tamaño visual y amplían el área táctil con ::after; el espaciado evita solapes. */
@media (pointer: coarse), (max-width: 640px) {
  .kind, .chip, .theme, .seg-btn, .btn-ghost, .check, .logo, details summary { min-height: 44px; }
  details summary { display: flex; align-items: center; }
  .icon-btn { position: relative; }
  .icon-btn::after { content: ""; position: absolute; inset: -6px; }
  .top-actions, #userBox { gap: 8px; }
  #userBox { min-height: 44px; }
  .swatch:not(.custom) { position: relative; }
  .swatch:not(.custom)::after { content: ""; position: absolute; inset: -10px; border-radius: var(--r-pill); }
  .swatch.custom input { inset: -10px; width: auto; height: auto; }
  .palette { gap: 14px; }
}
@media (max-width: 380px) {
  .logo-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
@media (prefers-reduced-transparency: reduce) {
  .dialog::backdrop { background: var(--bg); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Páginas legales (/privacidad, /terminos) */
.legal { gap: 12px; line-height: 1.6; }
.legal h1 { font-family: var(--pixel); font-size: var(--fs-lg); line-height: 1.5; margin: 0; }
.legal h2 { font-size: var(--fs-md); margin: 12px 0 0; }
.legal p, .legal ul { margin: 0; }
.legal ul { padding-left: 20px; display: grid; gap: 6px; }
.legal-note { font-size: var(--fs-xs); }
