/* ==========================================================================
   Stetic Center · Catálogos — sistema visual
   Colores de marca: azul #17526d · turquesa #0b87a2 · menta #74ccc0
   ========================================================================== */
:root {
  --navy: #17526d;
  --navy-deep: #0c2b4b;
  --teal: #0b87a2;
  --mint: #74ccc0;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  font-family: "Poppins", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;

  /* Fondo (degradado + red animada) */
  --bg-a: #0c2b4b;
  --bg-b: #114466;
  --bg-c: #1a8aa3;
  --on-bg: #eef8fa;
  --on-bg-muted: rgba(226, 243, 248, .74);
  --on-bg-line: rgba(255, 255, 255, .16);
  --glass: rgba(255, 255, 255, .07);
  --glass-line: rgba(255, 255, 255, .13);

  /* Superficies — modo claro */
  color-scheme: light;
  --card: #ffffff;
  --soft: #eaf3f6;
  --soft-2: #d9eaf0;
  --text: #10303d;
  --muted: #5b7480;
  --line: rgba(23, 82, 109, .12);
  --ink: #17526d;
  --primary: #17526d;
  --danger: #c0392b;
  --danger-soft: #fdeceb;
  --tile-bg: #dce8ec;
  --input-bg: #f4f8fa;
  --drop-bg: #f5fafb;
  --drop-line: #b6d4dc;
  --drop-hover: #e7f5f8;
  --toast: #0c2b4b;
  --toast-fg: #ffffff;
  --banner-bg: #fff6e0;
  --banner-fg: #6f5200;
  --shadow: 0 1px 2px rgba(12, 43, 75, .06), 0 10px 28px rgba(12, 43, 75, .10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg-a: #050f1c; --bg-b: #0a2538; --bg-c: #0f5a6e;
    --card: #0f2432; --soft: #17344a; --soft-2: #21435b;
    --text: #e6f1f4; --muted: #93acb6; --line: rgba(255, 255, 255, .08);
    --ink: #8fd6cc; --primary: #1d6d8c; --danger: #ff8f80; --danger-soft: rgba(255, 143, 128, .12);
    --tile-bg: #142c3a; --input-bg: #0a1c27; --drop-bg: #0c2230; --drop-line: #2c5163; --drop-hover: #12303f;
    --toast: #e6f1f4; --toast-fg: #0c2b4b; --banner-bg: #3a2f10; --banner-fg: #f5d98a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px rgba(0, 0, 0, .32);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-a: #050f1c; --bg-b: #0a2538; --bg-c: #0f5a6e;
  --card: #0f2432; --soft: #17344a; --soft-2: #21435b;
  --text: #e6f1f4; --muted: #93acb6; --line: rgba(255, 255, 255, .08);
  --ink: #8fd6cc; --primary: #1d6d8c; --danger: #ff8f80; --danger-soft: rgba(255, 143, 128, .12);
  --tile-bg: #142c3a; --input-bg: #0a1c27; --drop-bg: #0c2230; --drop-line: #2c5163; --drop-hover: #12303f;
  --toast: #e6f1f4; --toast-fg: #0c2b4b; --banner-bg: #3a2f10; --banner-fg: #f5d98a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px rgba(0, 0, 0, .32);
}

/* Logo a color (claro) o blanco (oscuro) donde va sobre tarjeta */
.on-dark { display: none !important; }
.theme-btn .i-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .on-light { display: none !important; }
  :root:not([data-theme="light"]) .on-dark:not([hidden]) { display: block !important; }
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: none; }
}
:root[data-theme="dark"] .on-light { display: none !important; }
:root[data-theme="dark"] .on-dark:not([hidden]) { display: block !important; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text); background: var(--bg-a);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; color: inherit; }
input, textarea, select, button { font-family: inherit; }
img { display: block; }
::selection { background: rgba(116, 204, 192, .35); }
.muted { color: var(--muted); }

/* ---------- Fondo animado ---------- */
.bg-layer, .bg-canvas { position: fixed; inset: 0; pointer-events: none; }
.bg-layer {
  z-index: -2;
  background:
    radial-gradient(60% 45% at 80% 92%, rgba(120, 215, 230, .30), transparent 70%),
    radial-gradient(40% 30% at 12% 18%, rgba(116, 204, 192, .10), transparent 70%),
    linear-gradient(165deg, var(--bg-a) 0%, var(--bg-b) 50%, var(--bg-c) 100%);
}
.bg-canvas { z-index: -1; width: 100%; height: 100%; }

/* ---------- Botones ---------- */
.btn {
  position: relative; overflow: hidden; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border: 1px solid transparent; border-radius: 12px;
  font-size: 14.5px; font-weight: 600; letter-spacing: .01em; text-decoration: none; white-space: nowrap;
  color: var(--ink); background: var(--soft);
  transition: transform .2s var(--ease), box-shadow .25s ease, background-color .2s, color .2s, border-color .2s;
}
.btn svg { flex: none; }
.btn.primary { color: #fff; background: linear-gradient(135deg, #17526d, #1f6f90); box-shadow: 0 6px 16px rgba(23, 82, 109, .30); }
.btn.share { color: #fff; background: linear-gradient(135deg, #0b87a2 0%, #17526d 100%); box-shadow: 0 8px 22px rgba(11, 135, 162, .38); }
.btn.ghost { color: var(--ink); background: var(--card); border-color: var(--line); }
.btn.danger { color: var(--danger); background: var(--danger-soft); }
.btn.big { width: 100%; min-height: 52px; font-size: 15.5px; border-radius: 14px; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
@media (hover: hover) {
  .btn:hover:not(:disabled) { transform: translateY(-1px); }
  .btn.share:hover:not(:disabled), .btn.primary:hover:not(:disabled) { box-shadow: 0 12px 26px rgba(11, 135, 162, .42); }
  .btn.ghost:hover:not(:disabled) { border-color: rgba(11, 135, 162, .4); }
}
.icon-btn {
  position: relative; overflow: hidden; width: 40px; height: 40px; flex: none;
  display: grid; place-items: center; border-radius: 12px;
  color: #fff; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14);
  transition: background .2s, transform .2s var(--ease);
}
.icon-btn:hover { background: rgba(255, 255, 255, .16); }
.icon-btn:active { transform: scale(.92); }
.theme-btn svg { transition: transform .5s var(--spring); }
.theme-btn:active svg { transform: rotate(60deg); }
.link-btn { border: 0; background: none; padding: 6px 4px; color: var(--mint); font-size: 13.5px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

/* Onda al tocar */
.ripple {
  position: absolute; z-index: 0; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: .2; transform: scale(0); animation: ripple .65s var(--ease) forwards;
}

/* ---------- Pantalla de bienvenida ---------- */
#splash {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background: radial-gradient(80% 60% at 50% 100%, #145a73 0%, #0c2b4b 55%, #071a2b 100%);
  transition: opacity .55s ease, visibility .55s;
}
#splash.hide { opacity: 0; visibility: hidden; }
.splash-in { display: grid; justify-items: center; gap: 18px; }
.splash-sym { width: 86px; height: 86px; animation: splashSym 1s var(--spring) both; filter: drop-shadow(0 8px 24px rgba(116, 204, 192, .35)); }
.splash-logo { width: 210px; height: auto; animation: rise .6s .3s var(--ease) both; }
.splash-bar { width: 120px; height: 3px; overflow: hidden; border-radius: 3px; background: rgba(255, 255, 255, .14); animation: fadeIn .4s .5s both; }
.splash-bar::after { content: ''; display: block; width: 40%; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--teal), var(--mint)); animation: loadbar 1s ease-in-out infinite; }

/* ---------- Encabezado de la app ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(6, 24, 39, .55); border-bottom: 1px solid rgba(255, 255, 255, .08);
  -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
  animation: slideDown .55s var(--ease) both;
}
.topbar-in { display: flex; align-items: center; gap: 12px; max-width: 960px; min-height: 62px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
#logoFull, #logoSym { display: flex; align-items: center; }
.topbar .logo { height: 28px; width: auto; animation: fadeIn .6s ease both; }
.topbar .sym { height: 30px; width: 30px; animation: popIn .4s var(--spring) both; }
.topbar h1 { flex: 1; min-width: 0; margin: 0; color: #fff; font-size: 17px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: rise .35s var(--ease) both; }
.topbar .theme-btn { margin-left: auto; }
.stripe { height: 2px; background: linear-gradient(90deg, transparent, var(--teal), var(--mint), var(--teal), transparent); background-size: 200% 100%; animation: stripe 6s linear infinite; opacity: .85; }

.app main { max-width: 960px; margin: 0 auto; padding: 22px 16px calc(130px + env(safe-area-inset-bottom)); }

/* ---------- Portada (inicio) ---------- */
.hero { padding: 4px 4px 20px; color: #fff; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--mint); }
.eyebrow::before { content: ''; width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
.hero-title { margin: 10px 0 6px; font-size: clamp(27px, 7.4vw, 40px); line-height: 1.12; font-weight: 700; letter-spacing: -.015em; }
.hero-title span { background: linear-gradient(90deg, #ffffff, var(--mint)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { max-width: 470px; margin: 0; font-size: 15px; line-height: 1.55; color: var(--on-bg-muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.stat { padding: 14px 12px; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-line); }
.stat b { display: block; font-size: 25px; font-weight: 700; line-height: 1.1; color: #fff; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--on-bg-muted); }
.section-label { margin: 6px 4px 12px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--on-bg-muted); }

/* Tarjetas del menú */
.menu { display: grid; gap: 12px; }
@media (min-width: 700px) { .menu { grid-template-columns: 1fr 1fr; } }
.menu-card {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 22px;
  color: #fff; text-decoration: none;
  background: linear-gradient(135deg, rgba(23, 82, 109, .96) 0%, rgba(11, 135, 162, .94) 70%, rgba(116, 204, 192, .92) 140%);
  border: 1px solid rgba(255, 255, 255, .16); box-shadow: 0 16px 36px rgba(0, 0, 0, .24);
  transition: transform .35s var(--ease), box-shadow .35s;
}
.menu-card.alt { background: var(--glass); border-color: var(--glass-line); box-shadow: none; }
.menu-card.off { pointer-events: none; }
.menu-card.off .mi, .menu-card.off .mc-text { opacity: .55; }
.menu-card::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 35%; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .22), transparent);
  animation: shine 5.5s ease-in-out infinite;
}
.menu-card.off::after { display: none; }
.mi { width: 56px; height: 56px; flex: none; display: grid; place-items: center; border-radius: 16px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22); }
.mi svg { animation: floaty 3.4s ease-in-out infinite; }
.mc-text { flex: 1; min-width: 0; }
.menu-card strong { display: block; font-size: 18px; font-weight: 600; letter-spacing: .01em; }
.mc-text span { font-size: 13.5px; opacity: .85; }
.chev { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .16); transition: transform .35s var(--spring), background .2s; }
.badge { position: absolute; top: 12px; right: 12px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .04em; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .2); }

.foot-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 34px; }
.admin-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border-radius: 999px;
  font-size: 13px; text-decoration: none; color: var(--on-bg-muted); border: 1px solid var(--on-bg-line); background: none;
  transition: background .2s, color .2s;
}
.admin-link:hover { background: rgba(255, 255, 255, .1); color: #fff; }

/* Instalar la app */
.install-card {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 18px; padding: 12px 14px;
  text-align: left; color: #fff; border-radius: 18px; background: var(--glass); border: 1px solid var(--glass-line);
  animation: rise .5s var(--ease) both;
}
.install-card img { width: 46px; height: 46px; flex: none; border-radius: 12px; box-shadow: 0 6px 16px rgba(0, 0, 0, .25); }
.install-card > span:not(.install-go) { flex: 1; min-width: 0; }
.install-card strong { display: block; font-size: 15.5px; font-weight: 600; }
.install-card small { display: block; font-size: 12.5px; opacity: .8; }
.install-go { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--navy)); animation: pulse 2.4s ease-in-out infinite; }
.ios-steps { display: grid; gap: 10px; margin: 0; padding-left: 20px; text-align: left; font-size: 14.5px; }
.ios-ico { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; }

/* ---------- Lista de catálogos ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 2px 4px 16px; color: #fff; }
.page-head h2 { margin: 6px 0 0; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.count-pill { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; white-space: nowrap; font-size: 12.5px; font-weight: 600; color: #fff; background: var(--glass); border: 1px solid var(--glass-line); }
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 700px) { .cat-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; } }
.cat-card {
  position: relative; overflow: hidden; isolation: isolate; display: block; aspect-ratio: 3 / 4;
  border-radius: 20px; color: #fff; text-decoration: none; background: var(--tile-bg);
  border: 1px solid rgba(255, 255, 255, .1); box-shadow: 0 14px 32px rgba(0, 0, 0, .26);
  transition: transform .35s var(--ease), box-shadow .35s;
}
.cat-cover { position: absolute; inset: 0; background: linear-gradient(150deg, var(--navy), var(--teal) 70%, var(--mint)); }
.cat-cover > img { width: 100%; height: 100%; object-fit: cover; transition: opacity .6s ease, transform .8s var(--ease); }
.cat-ph { position: absolute; inset: 0; display: grid; place-items: center; }
.cat-ph img { width: 52%; height: auto; opacity: .2; animation: floaty 5s ease-in-out infinite; }
.cat-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(4, 18, 30, 0) 38%, rgba(4, 18, 30, .88) 100%); }
.cat-badge { position: absolute; top: 10px; left: 10px; padding: 4px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--navy); background: rgba(255, 255, 255, .94); }
.cat-info { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 14px; }
.cat-info strong { display: block; font-size: 16px; font-weight: 700; line-height: 1.2; letter-spacing: .02em; }
.cat-info span { font-size: 12px; opacity: .82; }
.cat-go { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .22); transition: transform .35s var(--spring), background .25s; }
@media (hover: hover) {
  .menu-card:hover, .cat-card:hover { box-shadow: 0 22px 44px rgba(0, 0, 0, .32); }
  .menu-card:hover .chev, .cat-card:hover .cat-go { transform: translateX(4px); background: var(--teal); }
  .cat-card:hover .cat-cover > img { transform: scale(1.07); }
}
.menu-card:active, .cat-card:active { transform: scale(.97); }

/* ---------- Dentro de un catálogo ---------- */
.cat-hero {
  position: relative; overflow: hidden; isolation: isolate; margin-bottom: 14px; padding: 22px 20px;
  color: #fff; border-radius: 22px; border: 1px solid rgba(255, 255, 255, .14);
  background: linear-gradient(135deg, rgba(23, 82, 109, .94), rgba(11, 135, 162, .88));
  box-shadow: 0 18px 40px rgba(0, 0, 0, .26);
}
.cat-hero-bg { position: absolute; inset: -30px; z-index: -1; background-size: cover; background-position: center; opacity: .38; filter: blur(20px) saturate(125%); animation: heroZoom 14s ease-in-out infinite alternate; }
.cat-hero h2 { margin: 8px 0 12px; font-size: clamp(26px, 7vw, 34px); font-weight: 700; letter-spacing: .01em; line-height: 1.1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22); }

.pdf-card {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px; margin-bottom: 24px; padding: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
}
.pdf-ico {
  position: relative; overflow: hidden; width: 48px; height: 60px; display: grid; place-items: end center; padding-bottom: 9px;
  border-radius: 10px; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .1em;
  background: linear-gradient(160deg, var(--navy), var(--teal)); box-shadow: 0 8px 18px rgba(23, 82, 109, .3);
}
.pdf-ico::before { content: ''; position: absolute; top: 0; right: 0; width: 15px; height: 15px; border-bottom-left-radius: 7px; background: rgba(255, 255, 255, .38); }
.pdf-card .grow { min-width: 0; }
.pdf-card .grow strong { display: block; font-weight: 600; color: var(--text); }
.pdf-card .grow span { font-size: 13px; color: var(--muted); }
.pdf-card .acts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pdf-card .acts .btn { flex-direction: column; gap: 4px; min-height: 64px; padding: 8px 6px; font-size: 12.5px; border-radius: 14px; }

.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 4px 4px; }
.sec-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 19px; font-weight: 600; color: #fff; }
.sec-head h2 .count-pill { padding: 2px 10px; font-size: 12px; }
.sec-hint { margin: 0 4px 14px; font-size: 12.5px; color: var(--on-bg-muted); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.tile {
  position: relative; overflow: hidden; isolation: isolate; aspect-ratio: 3 / 4; cursor: pointer;
  border-radius: 16px; background: var(--tile-bg); border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .22); transition: transform .25s var(--ease), box-shadow .3s;
}
.tile > img { width: 100%; height: 100%; object-fit: cover; transition: opacity .55s ease, transform .35s var(--ease), border-radius .35s; }
.tile::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(0, 0, 0, .28), transparent 32%); }
.tile .num { position: absolute; z-index: 2; left: 8px; top: 8px; min-width: 26px; padding: 3px 8px; text-align: center; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; background: rgba(12, 43, 75, .72); border: 1px solid rgba(255, 255, 255, .2); }
.tile .check { position: absolute; z-index: 2; right: 8px; top: 8px; width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border-radius: 50%; color: transparent; background: rgba(0, 0, 0, .25); border: 2px solid rgba(255, 255, 255, .92); transition: background .2s, transform .25s var(--spring); }
.tile.sel { box-shadow: 0 0 0 3px var(--mint), 0 12px 26px rgba(0, 0, 0, .28); }
.tile.sel > img { transform: scale(.92); border-radius: 12px; }
.tile.sel .check { color: #fff; background: var(--teal); border-color: #fff; animation: pop .35s var(--spring); }
@media (hover: hover) { .tile:hover { transform: translateY(-3px); box-shadow: 0 16px 32px rgba(0, 0, 0, .3); } }
.tile:active { transform: scale(.97); }

.empty { padding: 42px 20px; text-align: center; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.empty-ico { width: 60px; height: 60px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 18px; color: var(--teal); background: var(--soft); }

/* Imágenes que aparecen suave al cargar */
.cat-cover > img, .tile > img, .a-tile img { opacity: 0; }
.cat-cover > img.loaded, .tile > img.loaded, .a-tile img.loaded { opacity: 1; }

/* Tarjetas de carga (skeleton) */
.skel { position: relative; overflow: hidden; border-radius: 20px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .06); }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .13), transparent); animation: shimmer 1.3s ease-in-out infinite; }
.skel-card { aspect-ratio: 3 / 4; }
.skel-hero { height: 128px; margin-bottom: 14px; border-radius: 22px; }
.skel-pdf { height: 150px; margin-bottom: 24px; }
.skel-title { width: 46%; height: 26px; margin: 6px 4px 18px; border-radius: 10px; }

/* ---------- Barra inferior flotante ---------- */
.sharebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); pointer-events: none; }
.sharebar-in {
  display: flex; gap: 8px; max-width: 600px; margin: 0 auto; padding: 8px; pointer-events: auto; border-radius: 20px;
  background: rgba(8, 28, 44, .74); border: 1px solid rgba(255, 255, 255, .12); box-shadow: 0 18px 44px rgba(0, 0, 0, .38);
  -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
}
.sharebar .btn.ghost { color: #fff; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .14); }
.sharebar .btn.share { flex: 1; min-width: 0; }
.sharebar:not([hidden]) { animation: barUp .5s var(--spring) both; }
.dl-btn { width: 52px; min-height: 52px; padding: 0; flex: none; border-radius: 14px; }

/* ---------- Visor de imagen ---------- */
.viewer { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; color: #fff; background: radial-gradient(120% 80% at 50% 110%, #0f3a50 0%, #061421 65%); }
.viewer:not([hidden]) { animation: fadeIn .25s ease both; }
.v-top { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; animation: slideDown .4s var(--ease) both; }
.v-top button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .14); transition: background .2s, transform .2s; }
.v-top button:active { transform: scale(.92); }
.v-top button.on { background: var(--teal); border-color: var(--teal); }
#vCount { padding: 6px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; background: rgba(255, 255, 255, .1); font-variant-numeric: tabular-nums; }
.v-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px 12px; touch-action: pan-y; }
.v-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
#vImg.swap { animation: zoomIn .35s var(--ease) both; }
.v-nav { position: absolute; top: 50%; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .18); transform: translateY(-50%); }
.v-nav.prev { left: 10px; } .v-nav.next { right: 10px; }
.v-bottom { width: 100%; max-width: 600px; margin: 0 auto; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); animation: rise .4s var(--ease) both; }
.v-acts { display: flex; gap: 10px; }
.v-acts .btn.share { flex: 1; }
.viewer .dl-btn { color: #fff; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); }

/* ---------- Ventanas, avisos, carga ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(3, 12, 20, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fadeIn .2s ease both; }
.modal { display: grid; gap: 14px; width: 100%; max-width: 360px; padding: 26px 22px; text-align: center; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 30px 70px rgba(0, 0, 0, .38); animation: popIn .35s var(--spring) both; }
.modal p { margin: 0; font-size: 15.5px; }
.spinner { width: 40px; height: 40px; margin: 0 auto; border-radius: 50%; background: conic-gradient(from 0deg, transparent 0 25%, var(--teal) 70%, var(--mint)); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); animation: spin .8s linear infinite; }
#toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 100; max-width: calc(100% - 32px);
  padding: 12px 18px; text-align: center; font-size: 14px; font-weight: 500; color: var(--toast-fg); background: var(--toast);
  border-radius: 14px; box-shadow: 0 14px 34px rgba(0, 0, 0, .3); opacity: 0; pointer-events: none;
  transform: translate(-50%, 24px) scale(.96); transition: opacity .3s ease, transform .4s var(--spring);
}
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.err { min-height: 1em; margin: 0; font-size: 14px; color: var(--danger); }
.err:not(:empty) { animation: shake .4s ease both; }

/* ==========================================================================
   Panel de administración (PC)
   ========================================================================== */
.admin-top {
  position: sticky; top: 0; z-index: 30; background: rgba(6, 24, 39, .6); border-bottom: 1px solid rgba(255, 255, 255, .08);
  -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%); animation: slideDown .5s var(--ease) both;
}
.admin-top-in { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; max-width: 1400px; margin: 0 auto; padding: 12px 24px; }
.admin-top .logo { height: 28px; width: auto; }
.admin-top .title { flex: 1; min-width: 140px; padding-left: 14px; font-size: 13.5px; color: rgba(255, 255, 255, .72); border-left: 1px solid rgba(255, 255, 255, .18); }
.admin-top .btn.ghost { color: #fff; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .16); }
.demo-banner { padding: 10px 24px; font-size: 14px; color: var(--banner-fg); background: var(--banner-bg); animation: slideDown .4s ease both; }

.layout { display: grid; grid-template-columns: 280px 1fr; align-items: start; gap: 22px; max-width: 1400px; margin: 0 auto; padding: 24px; }
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; padding: 16px; } }
.aside { position: sticky; top: 86px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); animation: rise .5s var(--ease) both; }
@media (max-width: 820px) { .aside { position: static; } }
.aside h3 { margin: 6px 8px 10px; font-size: 11.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.cat-list { display: grid; gap: 4px; margin: 0 0 12px; padding: 0; list-style: none; }
.cat-list li { display: flex; align-items: center; border-radius: 12px; transition: background .2s, box-shadow .2s; }
.cat-list li:hover { background: var(--soft); }
.cat-list li.active { background: var(--soft); box-shadow: inset 3px 0 0 var(--teal); }
.cat-pick { flex: 1; padding: 10px 12px; text-align: left; border: 0; border-radius: 12px; background: none; color: var(--text); font-weight: 600; letter-spacing: .02em; }
.cat-pick small { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--muted); }
.cat-list li.active .cat-pick { color: var(--ink); }
.mv { display: flex; flex-direction: column; gap: 2px; padding-right: 6px; }
.mv button { padding: 2px 6px; border: 0; border-radius: 6px; font-size: 10px; color: var(--muted); background: none; }
.mv button:hover:not(:disabled) { color: var(--ink); background: var(--soft-2); }
.mv button:disabled { opacity: .25; cursor: default; }
.new-cat { display: flex; gap: 6px; }
.new-cat .btn { min-width: 46px; padding: 0; font-size: 20px; }
.new-cat input, .login input, .login-form input {
  flex: 1; min-width: 0; width: 100%; padding: 12px 14px; font-size: 16px; color: var(--text);
  background: var(--input-bg); border: 1px solid var(--line); border-radius: 12px; transition: border-color .2s, box-shadow .2s;
}
.new-cat input:focus, .login input:focus, .login-form input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(11, 135, 162, .18); }

.ed-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.ed-head h2 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: .02em; color: #fff; }
.ed-head .btn.ghost { color: #fff; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); }
.ed-head .btn.danger { color: #ffb3a8; background: rgba(255, 143, 128, .12); border-color: rgba(255, 143, 128, .25); }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.panel { margin-bottom: 18px; padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.panel h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink); }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 12px; }
.panel-head .muted { font-size: 13px; }
.pdf-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.pdf-row .grow { flex: 1; min-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.drop {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; margin-top: 12px; padding: 24px;
  text-align: center; font-size: 14.5px; color: var(--muted); background: var(--drop-bg);
  border: 2px dashed var(--drop-line); border-radius: 16px; transition: border-color .2s, background .2s, transform .25s var(--ease);
}
.drop small { font-size: 12.5px; }
.drop-ico { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: linear-gradient(135deg, var(--teal), var(--navy)); box-shadow: 0 8px 18px rgba(11, 135, 162, .3); transition: transform .35s var(--spring); }
.drop:hover, .filedrag .drop { color: var(--ink); background: var(--drop-hover); border-color: var(--teal); }
.drop:hover .drop-ico, .filedrag .drop-ico { transform: translateY(-4px) scale(1.05); }
.filedrag .drop { animation: breathe 1.2s ease-in-out infinite; }

.sel-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 14px; padding: 10px 12px; background: var(--soft); border-radius: 14px; }
.sel-bar label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); cursor: pointer; }
.sel-bar .muted { font-size: 13px; }
.sel-bar .btn { margin-left: auto; }
.sel-bar input, .t-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--teal); cursor: pointer; }

.a-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px; margin-top: 16px; }
.a-tile { position: relative; overflow: hidden; cursor: grab; background: var(--card); border: 1px solid var(--line); border-radius: 16px; transition: transform .25s var(--ease), box-shadow .25s, outline-color .2s; }
.a-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.a-tile.dragging { opacity: .35; transform: scale(.96); }
.a-tile.mark-before { box-shadow: -4px 0 0 var(--teal); }
.a-tile.mark-after { box-shadow: 4px 0 0 var(--teal); }
.a-tile.file-over { outline: 3px solid var(--mint); outline-offset: -3px; }
.a-tile.selected { outline: 3px solid var(--teal); outline-offset: -3px; }
.a-tile.selected img.loaded { opacity: .8; }
.a-tile img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; pointer-events: none; background: var(--tile-bg); transition: opacity .5s ease; }
.a-tile .num { position: absolute; left: 8px; top: 8px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; background: rgba(12, 43, 75, .85); }
.t-check { position: absolute; right: 8px; top: 8px; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; border-radius: 9px; background: var(--card); box-shadow: var(--shadow); }
.a-tile.selected .t-check { animation: pop .3s var(--spring); }
.t-name { padding: 6px 10px 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; color: var(--muted); }
.t-actions { display: flex; justify-content: space-between; gap: 4px; padding: 6px; }
.t-actions button { height: 32px; min-width: 32px; padding: 0 8px; display: grid; place-items: center; border: 0; border-radius: 9px; font-size: 12px; font-weight: 600; color: var(--ink); background: var(--soft); transition: background .2s, transform .15s; }
.t-actions button:hover:not(:disabled) { background: var(--soft-2); }
.t-actions button:active:not(:disabled) { transform: scale(.92); }
.t-actions button.del { color: var(--danger); }
.t-actions button:disabled { opacity: .3; cursor: default; }

.login { display: grid; gap: 14px; max-width: 390px; margin: 70px auto; padding: 30px 28px; background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 30px 70px rgba(0, 0, 0, .35); animation: popIn .55s var(--spring) both; }
.login img { width: 100%; height: auto; margin-bottom: 4px; }
.login .admin-link { justify-self: center; color: var(--muted); border-color: var(--line); }
.login .admin-link:hover { color: var(--ink); background: var(--soft); }
.login-form { display: grid; gap: 12px; }
.login-form p { margin: 0; text-align: center; font-size: 14px; }
.login-title { font-size: 18px !important; font-weight: 600; color: var(--ink); }

/* ==========================================================================
   Animaciones
   ========================================================================== */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes zoomIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes barUp { from { opacity: 0; transform: translateY(120%); } to { opacity: 1; transform: none; } }
@keyframes shine { 0% { transform: translateX(-160%) skewX(-20deg); } 55%, 100% { transform: translateX(380%) skewX(-20deg); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes stripe { from { background-position: 0 0; } to { background-position: 200% 0; } }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(116, 204, 192, .5); } 50% { box-shadow: 0 0 0 10px rgba(116, 204, 192, 0); } }
@keyframes heroZoom { from { transform: scale(1.05); } to { transform: scale(1.25) translate(-2%, -2%); } }
@keyframes splashSym { 0% { opacity: 0; transform: scale(.4) rotate(-25deg); } 100% { opacity: 1; transform: none; } }
@keyframes loadbar { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.01); } }

/* Entrada escalonada (la agrega UIAnim.enter) */
.stagger > * { animation: rise .55s var(--ease) both; animation-delay: calc(min(var(--i, 0), 14) * 50ms); }
.anim-in { animation: rise .45s var(--ease) both; }

/* Sin animaciones si el teléfono lo pide */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .cat-cover > img, .tile > img, .a-tile img { opacity: 1 !important; }
}

/* Envío por partes */
.modal-note { font-size: 14px !important; line-height: 1.5; color: var(--muted); }
.parts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.part { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font-size: 13px; font-weight: 700; color: var(--muted); background: var(--soft); transition: background .3s, color .3s, transform .3s var(--spring); }
.part.now { color: #fff; background: linear-gradient(135deg, var(--teal), var(--navy)); transform: scale(1.12); box-shadow: 0 6px 16px rgba(11, 135, 162, .35); }
.part.done { color: #fff; background: var(--mint); animation: pop .35s var(--spring); }
