/* ============================================================
   Rutas IA - Sistema de diseno
   Tokens, componentes y utilidades. Sin dependencias externas.
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;

  --accent-400: #22d3ee;
  --accent-500: #06b6d4;

  --ok-bg:   #dcfce7;  --ok-fg:   #15803d;  --ok-line:  #86efac;
  --warn-bg: #fef3c7;  --warn-fg: #b45309;  --warn-line:#fcd34d;
  --err-bg:  #fee2e2;  --err-fg:  #b91c1c;  --err-line: #fca5a5;
  --info-bg: #e0f2fe;  --info-fg: #0369a1;  --info-line:#7dd3fc;

  --bg:        #f7f8fc;
  --bg-soft:   #eef1f8;
  --surface:   #ffffff;
  --surface-2: #fbfcfe;
  --surface-3: #f1f4fa;
  --line:      #e3e8f0;
  --line-soft: #eef1f6;
  --text:      #131a2b;
  --text-2:    #4a5568;
  --text-3:    #7a879c;
  --on-brand:  #ffffff;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 6px 16px -4px rgba(16, 24, 40, .10), 0 2px 6px -2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .18), 0 4px 10px -4px rgba(16, 24, 40, .06);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --wrap: 1200px;
  --wrap-narrow: 820px;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --t-fast: 140ms var(--ease);
  --t: 220ms var(--ease);

  --font: "Segoe UI", system-ui, -apple-system, "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "SF Mono", Menlo, monospace;
}

/* Tema oscuro: es el predeterminado de la plataforma.
   Fondo profundo tipo cielo nocturno para que los orbes de color
   y el mapa radial tengan sobre que respirar. */
html[data-theme="dark"] {
  --bg:        #070a1c;
  --bg-soft:   #0a0f26;
  --surface:   #10162f;
  --surface-2: #141b39;
  --surface-3: #1a2347;
  --line:      #26305a;
  --line-soft: #1d2648;
  --text:      #eef1ff;
  --text-2:    #a8b2d8;
  --text-3:    #7681ab;

  --brand-50:  #1b2350;
  --brand-100: #232d63;
  --brand-200: #2f3b7d;
  --brand-300: #8b93ff;

  --ok-bg:   #0f2f1f;  --ok-fg:   #6ee7a8;  --ok-line:  #1c5138;
  --warn-bg: #33260c;  --warn-fg: #fbbf5c;  --warn-line:#5a4416;
  --err-bg:  #3a1519;  --err-fg:  #fca5a5;  --err-line: #63252b;
  --info-bg: #0c2740;  --info-fg: #7dd3fc;  --info-line:#16465e;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45);
  --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, .55);
  --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, .7);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0 0 var(--sp-3); line-height: 1.22; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.95rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.02rem; }
p  { margin: 0 0 var(--sp-3); }
a  { color: var(--brand-600); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--brand-700); }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-5) 0; }

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

::selection { background: var(--brand-200); color: var(--text); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--brand-600); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* ---------- 3. Layout ---------- */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--sp-5); }
.wrap-narrow { max-width: var(--wrap-narrow); }

.page { padding-block: var(--sp-6) var(--sp-8); min-height: 60vh; }
.section { padding-block: var(--sp-6); }
.section + .section { padding-top: 0; }

.stack   { display: flex; flex-direction: column; gap: var(--sp-4); }
.row     { display: flex; align-items: center; gap: var(--sp-3); }
.row-wrap{ flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow    { flex: 1 1 auto; min-width: 0; }
.center  { text-align: center; }
.muted   { color: var(--text-2); }
.dim     { color: var(--text-3); font-size: .88rem; }
.nowrap  { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); }
.mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); }
.hidden { display: none !important; }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5);
}
.section-head h2 { margin-bottom: 4px; }
.section-head p  { margin: 0; color: var(--text-2); }

.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand-600);
}

/* ---------- 4. Cabecera ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: var(--sp-4); height: 68px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
  color: #fff; box-shadow: var(--shadow-sm);
}
.brand-name { font-size: 1.06rem; }
.brand-name small { display: block; font-size: .64rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }

.main-nav { display: flex; align-items: center; gap: 2px; margin-left: var(--sp-4); }
.main-nav a {
  padding: 8px 13px; border-radius: var(--r-md); color: var(--text-2);
  font-size: .93rem; font-weight: 600; transition: background var(--t-fast), color var(--t-fast);
}
.main-nav a:hover { background: var(--surface-3); color: var(--text); }
.main-nav a.is-active { background: var(--brand-50); color: var(--brand-700); }
html[data-theme="dark"] .main-nav a.is-active { color: var(--brand-300); }

.header-actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }

.nav-toggle { display: none; }

/* menu de usuario */
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-full);
  cursor: pointer; color: var(--text); font: inherit; font-size: .9rem; font-weight: 600;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.user-btn:hover { border-color: var(--brand-300); box-shadow: var(--shadow-xs); }
.avatar {
  width: 30px; height: 30px; border-radius: var(--r-full); flex: 0 0 auto;
  display: grid; place-items: center; color: #fff; font-size: .74rem; font-weight: 800; letter-spacing: .02em;
}
.avatar-lg { width: 54px; height: 54px; font-size: 1.1rem; }

.dropdown {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 244px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast);
}
.dropdown.is-open { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.dropdown-head strong { display: block; font-size: .94rem; }
.dropdown-head span { font-size: .8rem; color: var(--text-3); word-break: break-all; }
.dropdown a, .dropdown button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: var(--r-md); border: 0; background: none;
  color: var(--text-2); font: inherit; font-size: .9rem; font-weight: 500; text-align: left; cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-3); color: var(--text); }
.dropdown .danger:hover { background: var(--err-bg); color: var(--err-fg); }
.dropdown-sep { height: 1px; background: var(--line-soft); margin: 6px 4px; }

/* ---------- 5. Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--r-md); border: 1px solid transparent;
  font: inherit; font-size: .93rem; font-weight: 600; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }

.btn-primary { background: var(--brand-600); color: var(--on-brand); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-700); color: #fff; box-shadow: var(--shadow-md); }

.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--brand-300); color: var(--text); }

.btn-soft { background: var(--brand-50); color: var(--brand-700); }
.btn-soft:hover { background: var(--brand-100); color: var(--brand-700); }
html[data-theme="dark"] .btn-soft { color: var(--brand-300); }

.btn-danger { background: var(--err-bg); color: var(--err-fg); border-color: var(--err-line); }
.btn-danger:hover { background: var(--err-fg); color: #fff; border-color: var(--err-fg); }

.btn-sm { padding: 7px 13px; font-size: .84rem; border-radius: var(--r-sm); }
.btn-lg { padding: 14px 26px; font-size: 1rem; border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: var(--r-md); }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); cursor: pointer; transition: all var(--t-fast);
}
.icon-btn:hover { color: var(--brand-600); border-color: var(--brand-300); background: var(--surface-3); }

/* ---------- 6. Insignias ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: .74rem; font-weight: 700; letter-spacing: .01em; line-height: 1.5;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-cat { background: var(--surface-3); color: var(--text-2); }
.badge-level { background: var(--surface-3); color: var(--text-2); text-transform: capitalize; }
.badge-principiante { background: var(--ok-bg);   color: var(--ok-fg);   border-color: var(--ok-line); }
.badge-intermedio   { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-line); }
.badge-avanzado     { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line); }

.badge-publicado { background: var(--ok-bg);   color: var(--ok-fg);   border-color: var(--ok-line); }
.badge-pendiente { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line); }
.badge-borrador  { background: var(--surface-3); color: var(--text-2); border-color: var(--line); }
.badge-rechazado { background: var(--err-bg);  color: var(--err-fg);  border-color: var(--err-line); }
.badge-archivado { background: var(--surface-3); color: var(--text-3); border-color: var(--line); }
.badge-aprobada  { background: var(--ok-bg);   color: var(--ok-fg);   border-color: var(--ok-line); }
.badge-rechazada { background: var(--err-bg);  color: var(--err-fg);  border-color: var(--err-line); }
.badge-cambios   { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-line); }

.tag-pill {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-2); font-size: .76rem; font-weight: 600;
  border: 1px solid var(--line-soft); transition: all var(--t-fast);
}
a.tag-pill:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }

/* ---------- 7. Tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--sp-5); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { margin: 0; font-size: 1.02rem; }
.card-body { padding: var(--sp-5); }
.card-foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line-soft); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- 8. Hero ---------- */
.hero { position: relative; overflow: hidden; padding-block: var(--sp-8) var(--sp-7); }
.hero::before {
  content: ""; position: absolute; inset: -30% -10% auto -10%; height: 130%;
  background:
    radial-gradient(48% 46% at 18% 22%, color-mix(in srgb, var(--brand-400) 30%, transparent) 0%, transparent 62%),
    radial-gradient(42% 44% at 82% 14%, color-mix(in srgb, var(--accent-400) 26%, transparent) 0%, transparent 60%),
    radial-gradient(40% 40% at 60% 88%, color-mix(in srgb, var(--brand-300) 20%, transparent) 0%, transparent 60%);
  filter: blur(6px); pointer-events: none; z-index: 0;
}
.hero > .wrap { position: relative; z-index: 1; }
.hero-inner { max-width: 780px; margin-inline: auto; text-align: center; }
.hero h1 { margin-bottom: var(--sp-4); }
.hero h1 .accent {
  background: linear-gradient(105deg, var(--brand-600), var(--accent-500));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-lead { font-size: clamp(1rem, 1.6vw, 1.16rem); color: var(--text-2); margin-bottom: var(--sp-5); }

.hero-stats { display: flex; justify-content: center; gap: var(--sp-6); flex-wrap: wrap; margin-top: var(--sp-6); }
.hero-stat { text-align: center; }
.hero-stat b { display: block; font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; }
.hero-stat span { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); font-weight: 600; }

/* buscador grande */
.searchbar {
  position: relative; display: flex; align-items: center; gap: var(--sp-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-full);
  padding: 7px 7px 7px 20px; box-shadow: var(--shadow-md);
  transition: box-shadow var(--t), border-color var(--t);
}
.searchbar:focus-within { border-color: var(--brand-400); box-shadow: var(--shadow-lg); }
.searchbar svg { color: var(--text-3); flex: 0 0 auto; }
.searchbar input {
  flex: 1 1 auto; min-width: 0; border: 0; background: none; outline: none;
  font: inherit; font-size: 1.02rem; color: var(--text); padding: 10px 4px;
}
.searchbar input::placeholder { color: var(--text-3); }
.searchbar .btn { border-radius: var(--r-full); }

.search-hints { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: var(--sp-4); }
.search-hints span { font-size: .82rem; color: var(--text-3); align-self: center; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  padding: 5px 13px; border-radius: var(--r-full); font-size: .83rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all var(--t-fast);
}
.chip:hover { border-color: var(--brand-300); color: var(--brand-700); background: var(--brand-50); }
.chip.is-active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

/* ---------- 9. Tarjeta de uso ---------- */
.use-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }

.use-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-xs);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.use-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--brand-200); }
.use-card::after {
  content: ""; position: absolute; inset-inline: 0; top: 0; height: 3px;
  background: var(--cat-color, var(--brand-500)); opacity: 0; transition: opacity var(--t);
}
.use-card:hover::after { opacity: 1; }

.use-card-media { position: relative; aspect-ratio: 16 / 9; background: var(--surface-3); overflow: hidden; }
.use-card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 400ms var(--ease); }
.use-card:hover .use-card-media img { transform: scale(1.05); }
.use-card-media.is-glyph {
  display: grid; place-items: center;
  background:
    radial-gradient(120% 120% at 20% 0%, color-mix(in srgb, var(--cat-color, var(--brand-500)) 22%, transparent), transparent 65%),
    var(--surface-3);
  color: var(--cat-color, var(--brand-500));
}

.use-card-body { padding: var(--sp-4) var(--sp-5) var(--sp-3); display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; }
.use-card-top { display: flex; align-items: center; gap: 10px; }
.use-num {
  font-family: var(--mono); font-size: .78rem; font-weight: 700; letter-spacing: .04em;
  color: var(--cat-color, var(--brand-500)); background: color-mix(in srgb, var(--cat-color, var(--brand-500)) 12%, transparent);
  padding: 2px 8px; border-radius: var(--r-sm);
}
.use-cat {
  font-size: .7rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase;
  color: var(--cat-color, var(--brand-600));
}
.use-card h3 { margin: 0; font-size: 1.08rem; line-height: 1.3; }
.use-card h3 a { color: var(--text); }
.use-card h3 a:hover { color: var(--brand-600); }
.use-card p { margin: 0; color: var(--text-2); font-size: .91rem; line-height: 1.55; }
.use-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }

.use-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line-soft); background: var(--surface-2);
}
.use-card-foot .link-more {
  display: inline-flex; align-items: center; gap: 6px; font-size: .87rem; font-weight: 700; color: var(--brand-600);
}
.use-card-foot .link-more svg { transition: transform var(--t-fast); }
.use-card:hover .link-more svg { transform: translateX(3px); }

.fav-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: var(--r-full); border: 1px solid var(--line); background: var(--surface);
  color: var(--text-3); cursor: pointer; transition: all var(--t-fast);
}
.fav-btn:hover { color: #e11d48; border-color: #fda4af; background: #fff1f2; }
html[data-theme="dark"] .fav-btn:hover { background: #3a1519; }
.fav-btn.is-on { color: #e11d48; border-color: #fda4af; background: #fff1f2; }
html[data-theme="dark"] .fav-btn.is-on { background: #3a1519; border-color: #63252b; }
.fav-btn.is-on svg { fill: currentColor; }
.fav-btn.pulse { animation: pop 380ms var(--ease); }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.28); } 100% { transform: scale(1); } }

.featured-flag {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--line); color: #b45309;
  padding: 4px 10px; border-radius: var(--r-full); font-size: .72rem; font-weight: 700;
}
.featured-flag svg { fill: currentColor; }

/* ---------- 10. Categorias ---------- */
.cat-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.cat-card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: var(--sp-5); border-radius: var(--r-lg); border: 1px solid var(--line);
  background: var(--surface); overflow: hidden;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.cat-card::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--cat-color) 14%, transparent), transparent 60%);
  opacity: 0; transition: opacity var(--t);
}
.cat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--cat-color) 40%, var(--line)); }
.cat-card:hover::before { opacity: 1; }
.cat-card > * { position: relative; }
.cat-icon {
  width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center;
  background: color-mix(in srgb, var(--cat-color) 14%, transparent); color: var(--cat-color);
}
.cat-card h3 { margin: 0; font-size: 1.02rem; color: var(--text); }
.cat-card p { margin: 0; font-size: .86rem; color: var(--text-2); line-height: 1.5; }
.cat-count { margin-top: 4px; font-size: .8rem; font-weight: 700; color: var(--cat-color); }

/* ---------- 11. Filtros del explorador ---------- */
.explorer { display: grid; grid-template-columns: 260px 1fr; gap: var(--sp-6); align-items: start; }
.filters {
  position: sticky; top: 88px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--sp-5); box-shadow: var(--shadow-xs);
}
.filters h3 { font-size: .95rem; display: flex; align-items: center; gap: 8px; }
.filter-group { padding-block: var(--sp-4); border-top: 1px solid var(--line-soft); }
.filter-group:first-of-type { border-top: 0; padding-top: var(--sp-2); }
.filter-group > label, .filter-title {
  display: block; font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 10px;
}
.filter-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; margin: -4px; padding: 4px; }
.filter-list a {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--r-sm);
  font-size: .89rem; color: var(--text-2); font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}
.filter-list a:hover { background: var(--surface-3); color: var(--text); }
.filter-list a.is-active { background: var(--brand-50); color: var(--brand-700); font-weight: 700; }
html[data-theme="dark"] .filter-list a.is-active { color: var(--brand-300); }
.filter-list .count { margin-left: auto; font-size: .76rem; color: var(--text-3); font-variant-numeric: tabular-nums; }

.results-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  flex-wrap: wrap; margin-bottom: var(--sp-4);
}
.results-count { font-size: .92rem; color: var(--text-2); }
.results-count b { color: var(--text); }

.active-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: var(--sp-4); }
.filter-tag {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px 5px 12px;
  border-radius: var(--r-full); background: var(--brand-50); color: var(--brand-700);
  border: 1px solid var(--brand-200); font-size: .82rem; font-weight: 600;
}
html[data-theme="dark"] .filter-tag { color: var(--brand-300); }
.filter-tag a { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: inherit; }
.filter-tag a:hover { background: color-mix(in srgb, var(--brand-600) 20%, transparent); }

/* ---------- 12. Formularios ---------- */
.field { margin-bottom: var(--sp-4); }
.field > label, .label {
  display: block; margin-bottom: 6px; font-size: .87rem; font-weight: 600; color: var(--text);
}
.field .hint { display: block; margin-top: 6px; font-size: .8rem; color: var(--text-3); line-height: 1.5; }
.req { color: #e11d48; }

.input, .select, .textarea {
  width: 100%; padding: 11px 14px; font: inherit; font-size: .94rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--brand-200); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 18%, transparent);
}
.textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
.textarea-lg { min-height: 170px; }
.select {
  appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a879c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.input.has-error, .select.has-error, .textarea.has-error { border-color: var(--err-fg); }
.field-error { display: block; margin-top: 6px; font-size: .82rem; color: var(--err-fg); font-weight: 600; }

.form-grid { display: grid; gap: 0 var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

fieldset { border: 0; padding: 0; margin: 0 0 var(--sp-5); }
legend { padding: 0; font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin-bottom: var(--sp-3); }

.check-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.check {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  cursor: pointer; font-size: .88rem; font-weight: 500; transition: all var(--t-fast);
}
.check:hover { border-color: var(--brand-300); background: var(--surface-3); }
.check input { accent-color: var(--brand-600); width: 16px; height: 16px; cursor: pointer; flex: 0 0 auto; }
.check:has(input:checked) { border-color: var(--brand-400); background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
html[data-theme="dark"] .check:has(input:checked) { color: var(--brand-300); }

.radio-cards { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.radio-card {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); cursor: pointer;
  transition: all var(--t-fast);
}
.radio-card:hover { border-color: var(--brand-300); }
.radio-card input { accent-color: var(--brand-600); margin-top: 3px; flex: 0 0 auto; }
.radio-card strong { display: block; font-size: .9rem; }
.radio-card span { display: block; font-size: .79rem; color: var(--text-3); line-height: 1.45; }
.radio-card:has(input:checked) { border-color: var(--brand-500); background: var(--brand-50); box-shadow: 0 0 0 1px var(--brand-400); }

/* interruptor */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative; width: 46px; height: 26px; flex: 0 0 auto;
  background: var(--line); border-radius: var(--r-full); transition: background var(--t);
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform var(--t);
}
.switch input:checked + .switch-track { background: var(--brand-600); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 30%, transparent); }
.switch-label { font-size: .9rem; font-weight: 600; }

.form-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
  padding-top: var(--sp-5); margin-top: var(--sp-5); border-top: 1px solid var(--line-soft); flex-wrap: wrap;
}
.form-actions .grow { justify-content: flex-start; }

/* subida de imagen */
.upload-box {
  display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4);
  border: 1.5px dashed var(--line); border-radius: var(--r-md); background: var(--surface-2);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.upload-box:hover { border-color: var(--brand-300); background: var(--brand-50); }
.upload-preview { width: 96px; height: 66px; border-radius: var(--r-sm); object-fit: cover; border: 1px solid var(--line); background: var(--surface-3); }

/* ---------- 13. Detalle de un uso ---------- */
.detail-hero { padding-block: var(--sp-6) var(--sp-5); border-bottom: 1px solid var(--line); background: var(--surface); }
.detail-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.detail-title { max-width: 900px; }
.detail-lead { font-size: 1.1rem; color: var(--text-2); max-width: 760px; margin-bottom: var(--sp-4); }
.detail-meta { display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: center; color: var(--text-3); font-size: .86rem; }
.detail-meta span { display: inline-flex; align-items: center; gap: 6px; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-6); align-items: start; margin-top: var(--sp-6); }

.detail-block { margin-bottom: var(--sp-6); }
.detail-block > h2 {
  display: flex; align-items: center; gap: 10px; font-size: 1.18rem; margin-bottom: var(--sp-3);
}
.detail-block .marker {
  width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; flex: 0 0 auto;
  background: var(--brand-50); color: var(--brand-600);
}
html[data-theme="dark"] .detail-block .marker { color: var(--brand-300); }
.detail-block p { color: var(--text-2); line-height: 1.72; }
.prose p:last-child { margin-bottom: 0; }

ol.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
ol.steps li {
  position: relative; padding: 12px 16px 12px 50px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-2); line-height: 1.6;
}
ol.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 14px; top: 12px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand-600); color: #fff;
  font-size: .76rem; font-weight: 800;
}

.prompt-box {
  position: relative; border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-2);
}
.prompt-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 11px 14px; background: var(--surface-3); border-bottom: 1px solid var(--line);
}
.prompt-head strong { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); font-weight: 800; }
.prompt-body {
  margin: 0; padding: var(--sp-4) var(--sp-5); font-family: var(--mono); font-size: .875rem;
  line-height: 1.75; color: var(--text); white-space: pre-wrap; word-break: break-word;
  max-height: 460px; overflow: auto;
}

.callout {
  display: flex; gap: var(--sp-3); padding: var(--sp-4);
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2);
}
.callout .callout-icon { flex: 0 0 auto; color: var(--brand-600); margin-top: 2px; }
.callout-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); }
.callout-warn .callout-icon { color: var(--warn-fg); }
.callout-err  { background: var(--err-bg);  border-color: var(--err-line);  color: var(--err-fg); }
.callout-err .callout-icon { color: var(--err-fg); }
.callout-ok   { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok-fg); }
.callout-ok .callout-icon { color: var(--ok-fg); }
.callout p:last-child { margin-bottom: 0; }

.detail-side { position: sticky; top: 88px; display: flex; flex-direction: column; gap: var(--sp-4); }
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow-xs); }
.side-card h3 { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin-bottom: var(--sp-3); }
.side-list { display: flex; flex-direction: column; gap: 10px; }
.side-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); font-size: .89rem; }
.side-row .k { color: var(--text-3); }
.side-row .v { font-weight: 600; text-align: right; }

.tool-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px;
  border-radius: var(--r-full); border: 1px solid var(--line); background: var(--surface);
  font-size: .85rem; font-weight: 600; color: var(--text-2); transition: all var(--t-fast);
}
.tool-chip:hover { border-color: var(--tool-color, var(--brand-400)); color: var(--text); transform: translateY(-1px); box-shadow: var(--shadow-xs); }

.detail-image { border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); margin-bottom: var(--sp-5); }
.detail-image img { width: 100%; }

/* ---------- 14. Tablas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 720px; }
table.data th {
  text-align: left; padding: 12px 16px; background: var(--surface-3);
  font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background var(--t-fast); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { font-family: var(--mono); font-size: .82rem; color: var(--text-3); }
table.data .actions { display: flex; gap: 5px; justify-content: flex-end; }
table.data .cell-title { font-weight: 600; color: var(--text); }
table.data .cell-title a { color: var(--text); }
table.data .cell-title a:hover { color: var(--brand-600); }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell strong { display: block; font-size: .89rem; font-weight: 600; }
.user-cell span { display: block; font-size: .78rem; color: var(--text-3); }

/* ---------- 15. Panel de administracion ---------- */
.admin-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.admin-side {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: var(--sp-5) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-5);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-side .brand { padding-inline: 8px; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav .nav-title {
  font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3); padding: var(--sp-4) 12px 6px;
}
.admin-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--r-md);
  color: var(--text-2); font-size: .9rem; font-weight: 600; transition: all var(--t-fast);
}
.admin-nav a:hover { background: var(--surface-3); color: var(--text); }
.admin-nav a.is-active { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-sm); }
.admin-nav a.is-active:hover { color: #fff; }
.admin-nav .pill {
  margin-left: auto; background: var(--warn-bg); color: var(--warn-fg);
  border-radius: var(--r-full); padding: 1px 8px; font-size: .72rem; font-weight: 800;
}
.admin-nav a.is-active .pill { background: rgba(255,255,255,.22); color: #fff; }

.admin-main { min-width: 0; background: var(--bg); }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6); background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.admin-topbar h1 { font-size: 1.35rem; margin: 0; }
.admin-content { padding: var(--sp-6); }

.stat-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat {
  position: relative; padding: var(--sp-5); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-xs); overflow: hidden;
}
.stat-icon {
  width: 38px; height: 38px; border-radius: var(--r-md); display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand-600); margin-bottom: var(--sp-3);
}
html[data-theme="dark"] .stat-icon { color: var(--brand-300); }
.stat b { display: block; font-size: 1.85rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat span { font-size: .82rem; color: var(--text-3); font-weight: 600; }
.stat.accent-warn .stat-icon { background: var(--warn-bg); color: var(--warn-fg); }
.stat.accent-ok   .stat-icon { background: var(--ok-bg);   color: var(--ok-fg); }
.stat.accent-info .stat-icon { background: var(--info-bg); color: var(--info-fg); }

.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 46px; gap: 12px; align-items: center; font-size: .87rem; }
.bar-row .bar-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 9px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-full); background: var(--brand-500); transition: width 600ms var(--ease); }
.bar-row .bar-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.spark { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.spark-bar { flex: 1 1 0; min-width: 4px; background: var(--brand-200); border-radius: 3px 3px 0 0; transition: background var(--t-fast); }
.spark-bar:hover { background: var(--brand-500); }

.perm-table { width: 100%; border-collapse: collapse; }
.perm-table th, .perm-table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.perm-table thead th { background: var(--surface-3); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.perm-table td.center, .perm-table th.center { text-align: center; }
.perm-table .perm-name { font-weight: 600; font-size: .91rem; }
.perm-table .perm-desc { font-size: .81rem; color: var(--text-3); margin-top: 2px; }
.perm-table .locked { color: var(--ok-fg); }

/* ---------- 16. Avisos y toasts ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 11px; padding: 13px 16px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2);
  font-size: .91rem; margin-bottom: var(--sp-4);
}
.alert svg { flex: 0 0 auto; margin-top: 2px; }
.alert-success { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok-fg); }
.alert-error   { background: var(--err-bg);  border-color: var(--err-line);  color: var(--err-fg); }
.alert-info    { background: var(--info-bg); border-color: var(--info-line); color: var(--info-fg); }
.alert-warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); }

#toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 360px;
  padding: 12px 16px; border-radius: var(--r-md); background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg); font-size: .9rem; font-weight: 600;
  animation: toastIn 260ms var(--ease);
}
.toast.is-out { animation: toastOut 220ms var(--ease) forwards; }
.toast-ok  { background: #16a34a; color: #fff; }
.toast-err { background: #dc2626; color: #fff; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ---------- 17. Estados vacios y paginacion ---------- */
.empty {
  text-align: center; padding: var(--sp-8) var(--sp-5);
  border: 1.5px dashed var(--line); border-radius: var(--r-lg); background: var(--surface-2);
}
.empty-icon {
  width: 60px; height: 60px; border-radius: var(--r-lg); margin: 0 auto var(--sp-4);
  display: grid; place-items: center; background: var(--surface-3); color: var(--text-3);
}
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--text-2); max-width: 440px; margin-inline: auto; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: var(--sp-6); flex-wrap: wrap; }
.pagination a, .pagination span {
  display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding-inline: 12px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface);
  font-size: .88rem; font-weight: 600; color: var(--text-2); transition: all var(--t-fast);
}
.pagination a:hover { border-color: var(--brand-400); color: var(--brand-600); }
.pagination .is-current { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.pagination .is-disabled { opacity: .45; pointer-events: none; }

/* ---------- 18. Autenticacion ---------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside {
  position: relative; overflow: hidden; padding: var(--sp-8) var(--sp-7);
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(150deg, #312e81 0%, #4338ca 42%, #0e7490 100%); color: #fff;
}
.auth-aside::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(60% 50% at 80% 15%, rgba(255,255,255,.18), transparent 60%),
              radial-gradient(50% 40% at 10% 90%, rgba(34,211,238,.25), transparent 60%);
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside h2 { font-size: 2rem; max-width: 460px; }
.auth-aside p { color: rgba(255,255,255,.86); max-width: 440px; }
.auth-aside .brand, .auth-aside .brand:hover { color: #fff; }
.auth-aside .brand-mark { background: rgba(255,255,255,.16); backdrop-filter: blur(6px); }
.auth-aside .brand-name small { color: rgba(255,255,255,.66); }
.auth-points { display: flex; flex-direction: column; gap: 14px; margin-top: var(--sp-6); }
.auth-point { display: flex; align-items: flex-start; gap: 12px; }
.auth-point-icon {
  width: 34px; height: 34px; border-radius: var(--r-md); flex: 0 0 auto; display: grid; place-items: center;
  background: rgba(255,255,255,.16);
}
.auth-point strong { display: block; font-size: .95rem; }
.auth-point span { font-size: .85rem; color: rgba(255,255,255,.8); }

.auth-main { display: grid; place-items: center; padding: var(--sp-6); background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: 6px; }
.auth-card > p { color: var(--text-2); margin-bottom: var(--sp-5); }

.demo-box {
  margin-top: var(--sp-5); padding: var(--sp-4); border-radius: var(--r-md);
  background: var(--surface-2); border: 1px dashed var(--line); font-size: .84rem;
}
.demo-box strong { display: block; margin-bottom: 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.demo-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; color: var(--text-2); }
.demo-row code { font-family: var(--mono); font-size: .8rem; color: var(--text); }

/* ---------- 19. Pie ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding-block: var(--sp-6); margin-top: var(--sp-8); }
.footer-grid { display: grid; gap: var(--sp-5); grid-template-columns: 1.4fr 1fr 1fr; }
.site-footer h4 { font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin-bottom: var(--sp-3); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.site-footer a { color: var(--text-2); font-size: .9rem; }
.site-footer a:hover { color: var(--brand-600); }
.footer-bottom {
  margin-top: var(--sp-6); padding-top: var(--sp-4); border-top: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
  font-size: .84rem; color: var(--text-3);
}

/* ---------- 20. Utilidades varias ---------- */
.divider-label { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: .8rem; margin-block: var(--sp-4); }
.divider-label::before, .divider-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: grid; grid-template-columns: 30px 1fr; gap: 14px; padding-bottom: var(--sp-4); position: relative; }
.timeline-item::before { content: ""; position: absolute; left: 14px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); z-index: 1; }
.timeline-body strong { display: block; font-size: .91rem; }
.timeline-body span { font-size: .82rem; color: var(--text-3); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: .89rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 600; }

.reveal { opacity: 0; transform: translateY(16px); }
.reveal.is-in { opacity: 1; transform: none; transition: opacity 520ms var(--ease), transform 520ms var(--ease); }

.loading-grid { opacity: .45; pointer-events: none; transition: opacity var(--t); }

/* ---------- 21. Responsive ---------- */
@media (max-width: 1080px) {
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .explorer { grid-template-columns: 230px 1fr; }
}

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side {
    position: static; height: auto; flex-direction: row; align-items: center;
    overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); gap: var(--sp-4);
  }
  .admin-side .admin-nav { flex-direction: row; }
  .admin-nav .nav-title { display: none; }
  .admin-side .side-foot { display: none; }
  .admin-content { padding: var(--sp-5) var(--sp-4); }
  .admin-topbar { padding: var(--sp-4); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 780px) {
  .wrap { padding-inline: var(--sp-4); }
  .nav-toggle { display: inline-grid; }
  .main-nav {
    position: absolute; left: 0; right: 0; top: 68px; margin: 0;
    flex-direction: column; align-items: stretch; gap: 2px; padding: var(--sp-3);
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-md);
    display: none;
  }
  .main-nav.is-open { display: flex; }
  .main-nav a { padding: 12px 14px; }
  .explorer { grid-template-columns: 1fr; }
  .filters { position: static; }
  .filters.is-collapsed .filter-body { display: none; }
  .hero { padding-block: var(--sp-6); }
  .hero-stats { gap: var(--sp-5); }
  .use-grid { grid-template-columns: 1fr; }
  .form-actions { justify-content: stretch; }
  .form-actions .btn { flex: 1 1 auto; }
  .footer-grid { grid-template-columns: 1fr; }
  .detail-layout { gap: var(--sp-5); }
}

@media (max-width: 520px) {
  .searchbar { padding-left: 14px; }
  .searchbar .btn span { display: none; }
  .searchbar .btn { width: 42px; padding: 0; }
  .hero-stat b { font-size: 1.4rem; }
  .card-pad, .card-body { padding: var(--sp-4); }
  .stat { padding: var(--sp-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header, .site-footer, .detail-side, .filters, .btn, .fav-btn { display: none !important; }
  body { background: #fff; }
}

/* ============================================================
   22. Lenguaje visual "cosmico": orbes, tipografia display
       y mapa radial de categorias.
   ============================================================ */

/* ---------- Orbes ambientales ---------- */
.ambient { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.ambient-orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; }
.orb-1 { width: min(620px, 72vw); aspect-ratio: 1; background: #4a36ff; top: -22%; left: -10%; }
.orb-2 { width: min(540px, 62vw); aspect-ratio: 1; background: #06b6d4; top: -14%; right: -12%; opacity: .38; }
.orb-3 { width: min(480px, 56vw); aspect-ratio: 1; background: #a855f7; bottom: -34%; left: 36%; opacity: .34; }
html[data-theme="light"] .ambient-orb { opacity: .22; filter: blur(80px); }

/* ---------- Tipografia display ---------- */
.display {
  font-family: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI Semibold", Impact, "Arial Narrow", sans-serif;
  font-weight: 700;
  font-stretch: 87.5%;
  text-transform: uppercase;
  letter-spacing: -.02em;
  line-height: 1;
  font-size: clamp(1.75rem, 4vw, 3rem);
  margin-bottom: var(--sp-3);
}
.display .line { display: block; }
.display .tint {
  background: linear-gradient(100deg, var(--brand-300) 0%, var(--accent-400) 60%, #f0abfc 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
html[data-theme="light"] .display .tint {
  background: linear-gradient(100deg, var(--brand-600), var(--accent-500) 70%, #c026d3);
  -webkit-background-clip: text; background-clip: text;
}

/* ---------- Mapa radial de categorias ---------- */
.map-section { position: relative; overflow: hidden; }

.sector-map {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin-inline: auto;
  aspect-ratio: 1100 / 720;
}

.sector-map .map-lines {
  position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible;
}
.map-orbit { fill: none; stroke: var(--line); stroke-dasharray: 3 8; opacity: .8; }
.map-spoke { stroke: var(--line); stroke-width: 1; opacity: .55; }
.map-dot   { fill: var(--line); }

/* nucleo */
.map-center {
  position: absolute; left: 50%; top: 50%;
  width: 22.5%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: grid; place-items: center; text-align: center; gap: 2px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--brand-300) 45%, transparent);
  background:
    radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--brand-500) 34%, transparent), transparent 68%),
    var(--surface);
  box-shadow: 0 0 0 12px color-mix(in srgb, var(--brand-500) 7%, transparent),
              0 24px 60px -20px color-mix(in srgb, var(--brand-500) 60%, transparent);
  color: var(--text); text-decoration: none;
  transition: transform var(--t), box-shadow var(--t);
}
.map-center:hover {
  color: var(--text);
  transform: translate(-50%, -50%) scale(1.04);
  box-shadow: 0 0 0 16px color-mix(in srgb, var(--brand-500) 10%, transparent),
              0 28px 70px -18px color-mix(in srgb, var(--brand-500) 75%, transparent);
}
.map-center .kicker {
  font-size: .62rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--text-3);
}
.map-center .count {
  font-family: "Bahnschrift", "Segoe UI Variable Display", Impact, sans-serif;
  font-size: clamp(1.9rem, 4.4vw, 3.1rem); font-weight: 700; line-height: 1; letter-spacing: -.03em;
}
.map-center .label { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }

/* nodos */
.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 15.5%; min-width: 148px;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 13px 8px 8px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  color: var(--text); text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t), border-color var(--t), box-shadow var(--t), background var(--t);
}
.map-node:hover {
  color: var(--text);
  transform: translate(-50%, -50%) scale(1.07);
  border-color: var(--cat-color);
  background: var(--surface);
  box-shadow: 0 18px 40px -14px color-mix(in srgb, var(--cat-color) 65%, transparent);
  z-index: 3;
}
.map-node .ini {
  width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .7rem; font-weight: 800; letter-spacing: .02em;
  background: color-mix(in srgb, var(--cat-color) 20%, transparent);
  color: var(--cat-color);
  border: 1px solid color-mix(in srgb, var(--cat-color) 40%, transparent);
}
.map-node .name {
  flex: 1 1 auto; min-width: 0;
  font-size: .82rem; font-weight: 600; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.map-node .n {
  flex: 0 0 auto; font-size: .72rem; font-weight: 800; color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.map-node:hover .n { color: var(--cat-color); }

.map-fallback { display: none; }

@media (max-width: 900px) {
  .sector-map { display: none; }
  .map-fallback { display: grid; }
}

/* El heroe cosmico usa los orbes en vez del degradado plano anterior. */
.hero-cosmic::before { display: none; }
.hero-cosmic .hero-inner { position: relative; z-index: 1; }
/* El heroe es corto a proposito: el mapa entra casi de inmediato. */
.hero-cosmic { padding-block: var(--sp-7) var(--sp-5); }
.hero-cosmic .hero-lead { font-size: 1.02rem; margin-bottom: var(--sp-4); max-width: 640px; margin-inline: auto; }
.hero-cosmic .searchbar { max-width: 720px; margin-inline: auto; }

/* Las cifras pasan a acompanar al mapa */
.map-section .hero-stats { margin-top: var(--sp-6); }

@media (max-width: 780px) {
  .hero-cosmic { padding-block: var(--sp-6) var(--sp-4); }
}

/* ---------- Recursos de tipo comando ---------- */
.badge-comando {
  background: color-mix(in srgb, var(--accent-500) 16%, transparent);
  color: var(--accent-400);
  border-color: color-mix(in srgb, var(--accent-500) 40%, transparent);
  font-family: var(--mono);
  letter-spacing: 0;
}
html[data-theme="light"] .badge-comando { color: #0e7490; }

.prompt-box.is-command {
  border-color: color-mix(in srgb, var(--accent-500) 40%, var(--line));
}
.prompt-box.is-command .prompt-head {
  background: color-mix(in srgb, var(--accent-500) 12%, var(--surface-3));
  border-bottom-color: color-mix(in srgb, var(--accent-500) 34%, var(--line));
}
.prompt-box.is-command .prompt-body {
  background: color-mix(in srgb, var(--accent-500) 5%, var(--surface-2));
  font-size: .92rem;
  white-space: pre-wrap;
}
/* Cada linea del comando arranca con un indicador, como en una consola. */
.prompt-box.is-command .prompt-body::before {
  content: "";
  display: block;
  height: 0;
}
.prompt-box.is-command .prompt-body {
  padding-left: calc(var(--sp-5) + 4px);
  border-left: 3px solid color-mix(in srgb, var(--accent-500) 55%, transparent);
}

/* Sin pie de pagina: el contenido necesita su propio cierre inferior. */
main { padding-bottom: var(--sp-8); }
