/* ═══════════════════════════════════════════════════════════════
   RESET + BASE
   ═══════════════════════════════════════════════════════════════ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  min-height: 100vh;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--dur) ease, color var(--dur) ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { font-family: inherit; cursor: pointer; }

/* ═══════════════════════════════════════════════════════════════
   TOPBAR (legacy público)
   ═══════════════════════════════════════════════════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-6);
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.topbar-logo {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.topbar-nav { display: flex; align-items: center; gap: var(--sp-4); }

.topbar-link {
  color: var(--text-secondary);
  background: none; border: none;
  font-size: 14px; font-weight: 500;
  padding: 0;
}
.topbar-link:hover { color: var(--text-primary); }

.topbar-cta {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff !important;
  border-radius: var(--r-full);
  font-size: 13px; font-weight: 600;
}
.topbar-cta:hover { background: var(--accent-hover); }

.app-content { padding: var(--sp-6); max-width: 1200px; margin: 0 auto; }

.flash-stack {
  max-width: 480px; margin: 0 auto var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-2);
}

.flash {
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  border-left: 3px solid;
  animation: flashIn var(--dur-slow) var(--ease);
}
.flash-success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.flash-danger, .flash-error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.flash-warning { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }
.flash-info { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

@keyframes flashIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   AUTH PAGES
   ═══════════════════════════════════════════════════════════════ */
.auth-page {
  min-height: calc(100vh - 120px);
  display: grid; place-items: center;
  padding: var(--sp-6);
}

.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--r-xl);
  padding: var(--sp-8) var(--sp-6) var(--sp-6);
  box-shadow: var(--shadow-md);
}

.auth-title {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 600;
  letter-spacing: -0.8px;
  text-align: center;
  margin-bottom: var(--sp-2);
}

.auth-sub {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: var(--sp-6);
}

.auth-form { display: flex; flex-direction: column; gap: var(--sp-4); }

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
}

.input {
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all var(--dur) ease;
}
.input:focus {
  background: var(--bg-input-focus);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.input::placeholder { color: var(--text-muted); }

.field-error {
  font-size: 12.5px;
  color: var(--danger);
  margin-top: 2px;
}

.checkbox {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--text-secondary);
  cursor: pointer;
}

.btn {
  padding: 12px 20px;
  border-radius: var(--r-md);
  border: none;
  font-size: 14px; font-weight: 600;
  transition: all var(--dur) var(--ease);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-block { width: 100%; }

.auth-footer {
  text-align: center;
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border-color-soft);
}
.auth-footer a { font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR (navegación vertical IG-level)
   ═══════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  width: 245px;
  height: 100vh !important;
  min-height: 100vh !important;
  max-height: 100vh !important;
  padding: var(--sp-5) var(--sp-3) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  background: var(--bg-page);
  border-right: 1px solid var(--border-color-soft);
  z-index: 100;
  overflow: visible;
  transition: width var(--dur) var(--ease);
}

/* ── Logo ── */
.sidebar-logo {
  display: inline-flex;
  align-items: center;
  gap: 14px;             /* era 10px — más aire */
  padding: var(--sp-2) var(--sp-2);
  text-decoration: none;
  color: var(--text-primary);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-family: var(--font-display);
  font-weight: 800;         /* era 700 — más bold */
  font-size: 1.3em;         /* era 1.45em — menos pesado */
  letter-spacing: -0.03em;  /* era -0.02em — más tight */
  color: var(--text-primary);
  white-space: nowrap;
  line-height: 1;
  /* Ajuste óptico: el texto queda alineado al centro del ícono */
  padding-top: 2px;
}

/* El colibrí un toque más arriba para alinear ópticamente */
.sidebar-logo .brand-mark {
  margin-top: -1px;
}

/* ── Nav ── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto !important;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-primary);
  text-decoration: none;
  font-size: .95em;
  font-weight: 400;
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}

/* ── Icono del sidebar (contenedor con doble SVG apilado) ── */
.sidebar-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.sidebar-icon svg {
  position: absolute;
  inset: 0;
  width: 24px;
  height: 24px;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

/* Estado reposo: outline visible, filled oculto */
.sidebar-icon .icon-outline { opacity: 1; }
.sidebar-icon .icon-filled  { opacity: 0; }

/* Estado active: swap */
.sidebar-link.active .sidebar-icon .icon-outline { opacity: 0; }
.sidebar-link.active .sidebar-icon .icon-filled  { opacity: 1; }

/* Compatibilidad: SVG que no estén envueltos en .sidebar-icon */
.sidebar-link > svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  transition: transform var(--dur) var(--ease);
}

.sidebar-link:hover {
  background: var(--bg-hover);
}

.sidebar-link:hover .sidebar-icon svg,
.sidebar-link:hover > svg {
  transform: scale(1.05);
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-link:hover .sidebar-icon svg,
  .sidebar-link:hover > svg { transform: none; }
}

.sidebar-link:active {
  transform: scale(.98);
}

.sidebar-link-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Estado activo IG-level ── */
.sidebar-link.active {
  font-weight: 700;
}

.sidebar-link.active .sidebar-icon svg,
.sidebar-link.active > svg {
  filter: drop-shadow(0 0 4px var(--accent-soft));
}

.sidebar-link.active .sidebar-avatar {
  box-shadow: 0 0 0 2px var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-link.active .sidebar-icon svg,
  .sidebar-link.active > svg { filter: none; }
}

/* ── Avatar dentro del link "Perfil" ── */
.sidebar-avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-full);
  overflow: hidden;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
  font-size: .68em;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px var(--border-color);
}
.sidebar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sidebar-link.active .sidebar-avatar {
  box-shadow: 0 0 0 2px var(--accent);
}

.sidebar-icon .sidebar-avatar {
  position: static;
  inset: auto;
}

/* ── Footer del sidebar ── */
.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-color-soft);
  flex-shrink: 0 !important;
  margin-top: auto !important;
  position: relative;
  z-index: 10;
}

.sidebar-logout { display: contents; }
.sidebar-logout-btn { font: inherit; }

/* ── CTA (sin sesión) ── */
.sidebar-cta {
  display: block;
  margin-top: var(--sp-2);
  padding: 12px var(--sp-3);
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  text-align: center;
  font-weight: 600;
  font-size: .92em;
  text-decoration: none;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.sidebar-cta:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow-accent);
}
.sidebar-cta:active { transform: translateY(0); }

/* ── Badge del sidebar (Mensajes / Notificaciones) ── */
.sidebar-link-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-link[href*="/messages/"] .sidebar-link-badge {
  background: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   MAIN
   ═══════════════════════════════════════════════════════════════ */
.app-content {
  margin-left: 245px;
  min-height: 100vh;
  padding: 0 var(--sp-3);
  transition: margin-left var(--dur) var(--ease);
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE TOPBAR
   ═══════════════════════════════════════════════════════════════ */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 110;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg-page) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border-color-soft);
}

.mobile-topbar-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  text-decoration: none;
}

.mobile-topbar-title {
  font-family: var(--font-display);
  font-weight: 800;         /* era 700 */
  font-size: 1.15em;        /* ajustado */
  letter-spacing: -0.03em;  /* era -0.02em */
  color: var(--text-primary);
  white-space: nowrap;
  line-height: 1;
}

.mobile-topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mobile-topbar-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--dur) var(--ease);
}

.mobile-topbar-action:hover {
  background: var(--bg-hover);
}

.mobile-topbar-action svg {
  width: 24px;
  height: 24px;
}

.mobile-topbar-action.active svg {
  stroke-width: 2.5;
}

.mobile-topbar-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border: 2px solid var(--bg-page);
  box-sizing: content-box;
}

.mobile-topbar-action[href*="/messages/"] .mobile-topbar-badge {
  background: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE BOTTOM BAR
   ═══════════════════════════════════════════════════════════════ */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 110;
  height: 56px;
  padding: 0 8px;
  background: color-mix(in srgb, var(--bg-page) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border-color-soft);
  justify-content: space-evenly;
  align-items: center;
  gap: 2px;
}

.mobile-bottom-link {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-primary);
  text-decoration: none;
  transition: transform var(--dur) var(--ease);
}

.mobile-bottom-link:active {
  transform: scale(0.92);
}

.mobile-bottom-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.mobile-bottom-icon svg {
  position: absolute;
  inset: 0;
  width: 26px;
  height: 26px;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.mobile-bottom-icon .icon-outline { opacity: 1; }
.mobile-bottom-icon .icon-filled  { opacity: 0; }

.mobile-bottom-link.active .mobile-bottom-icon .icon-outline { opacity: 0; }
.mobile-bottom-link.active .mobile-bottom-icon .icon-filled  { opacity: 1; }

.mobile-bottom-link.active .mobile-bottom-icon svg {
  filter: drop-shadow(0 0 4px var(--accent-soft));
}

.mobile-bottom-link > svg {
  width: 26px;
  height: 26px;
  transition: all var(--dur) var(--ease);
}

.mobile-bottom-link.active > svg {
  stroke-width: 2.5;
  filter: drop-shadow(0 0 4px var(--accent-soft));
}

.mobile-bottom-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 12px;
  box-shadow: 0 0 0 1px var(--border-color);
}
.mobile-bottom-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.mobile-bottom-link.active .mobile-bottom-avatar {
  box-shadow: 0 0 0 2px var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   USER MENU (dropdown)
   ═══════════════════════════════════════════════════════════════ */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  width: 100%;
  border-radius: var(--r-md);
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--dur) var(--ease);
}

.user-menu-trigger:hover {
  background: var(--bg-hover);
}

.user-menu-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 700;
  font-size: .85em;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px var(--border-color);
}
.user-menu-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-menu-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
}

.user-menu-name {
  font-size: .9em;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.user-menu-handle {
  font-size: .75em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.user-menu-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--dur) var(--ease);
}

.user-menu-trigger[aria-expanded="true"] .user-menu-chevron {
  transform: rotate(180deg);
}

.user-menu-panel {
  position: absolute;
  top: auto;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 300;
  min-width: 240px;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: userMenuIn var(--dur) var(--ease);
}

.user-menu-panel[hidden] {
  display: none !important;
}

@keyframes userMenuIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-size: .9em;
  font-weight: 500;
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--dur) var(--ease);
}

.user-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.user-menu-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.user-menu-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.user-menu-item-danger { color: var(--danger); }
.user-menu-item-danger svg { color: var(--danger); }
.user-menu-item-danger:hover { background: var(--danger-soft); }

.user-menu-divider {
  margin: 6px 0;
  border: 0;
  border-top: 1px solid var(--border-color-soft);
}

.user-menu-logout { margin: 0; }

.user-menu-theme .icon-sun { display: none; }
.user-menu-theme .icon-moon { display: block; }
[data-theme="light"] .user-menu-theme .icon-sun { display: block; }
[data-theme="light"] .user-menu-theme .icon-moon { display: none; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) and (min-width: 641px) {
  .sidebar {
    width: 76px;
    padding: var(--sp-4) var(--sp-2) var(--sp-2);
  }
  .sidebar-logo-text,
  .sidebar-link-label {
    display: none;
  }
  .sidebar-logo {
    justify-content: center;
    padding: var(--sp-2) 0;
  }
  .sidebar-link {
    justify-content: center;
    padding: 12px 0;
  }
  .sidebar-link-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    margin-left: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 16px;
    transform: translate(50%, -50%);
  }
  .sidebar-cta {
    padding: 12px 6px;
    font-size: .72em;
  }
  .app-content {
    margin-left: 76px;
  }
  .user-menu-trigger {
    justify-content: center;
    padding: 8px 0;
  }
  .user-menu-meta,
  .user-menu-chevron {
    display: none;
  }
}

@media (max-width: 640px) {
  .sidebar {
    display: none !important;
  }
  .mobile-topbar {
    display: flex;
  }
  .mobile-bottom-bar {
    display: flex;
  }
  .app-content {
    margin-left: 0;
    padding: 0;
    padding-bottom: 64px;
  }
}

@media (max-width: 480px) {
  .flash-stack {
    margin: var(--sp-3) var(--sp-3);
    padding: 0;
    max-width: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TOGGLE DE TEMA
   ═══════════════════════════════════════════════════════════════ */
.sidebar-theme-toggle .icon-sun  { display: none; }
.sidebar-theme-toggle .icon-moon { display: block; }

[data-theme="light"] .sidebar-theme-toggle .icon-sun  { display: block; }
[data-theme="light"] .sidebar-theme-toggle .icon-moon { display: none; }

/* ═══════════════════════════════════════════════════════════════
   ANTI-LEAK NIVEL 1
   ═══════════════════════════════════════════════════════════════ */
.shop-product-media img,
.shop-gallery-thumb img,
.market-tile-media img,
.lightbox-img,
.product-lightbox-img,
.product-card-media-btn img,
.shop-tx-thumb img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT PÚBLICO
   ═══════════════════════════════════════════════════════════════ */
.public-body {
  background: var(--bg-page);
  color: var(--text-primary);
  margin: 0;
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.public-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  padding: var(--sp-4) var(--sp-8);
  background: color-mix(in srgb, var(--bg-page) 85%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color-soft);
}

.public-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.public-logo-mark {
  display: inline-block;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px var(--accent-soft));
}
.public-logo-mark-sm {
  width: 28px;
  height: 28px;
}

.public-nav {
  display: flex;
  gap: var(--sp-5);
}
.public-nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color var(--dur) var(--ease);
}
.public-nav-link:hover {
  color: var(--text-primary);
}

.public-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.public-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.public-theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.public-theme-toggle svg {
  width: 16px;
  height: 16px;
}
html[data-theme="dark"] .public-theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .public-theme-toggle .icon-moon { display: none; }

.public-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--dur) var(--ease);
  border: 1px solid transparent;
  white-space: nowrap;
}
.public-btn-ghost {
  color: var(--text-primary);
  border-color: var(--border-color);
  background: transparent;
}
.public-btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}
.public-btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-soft);
}
.public-btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-soft);
}

.public-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.public-footer {
  border-top: 1px solid var(--border-color-soft);
  padding: var(--sp-10) var(--sp-6);
  margin-top: var(--sp-10);
}
.public-footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  align-items: center;
  text-align: center;
}
.public-footer-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
}
.public-footer-tagline {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
}
.public-footer-links {
  display: flex;
  gap: var(--sp-5);
  flex-wrap: wrap;
  justify-content: center;
}
.public-footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color var(--dur) var(--ease);
}
.public-footer-links a:hover {
  color: var(--accent);
}
.public-footer-copy {
  color: var(--text-muted);
  font-size: 12px;
  margin: var(--sp-2) 0 0;
}

@media (max-width: 768px) {
  .public-header {
    padding: var(--sp-3) var(--sp-4);
  }
  .public-nav {
    display: none;
  }
  .public-actions .public-btn-ghost {
    display: none;
  }
  .public-logo-text {
    display: none;
  }
}
@media (max-width: 480px) {
  .public-actions .public-btn-primary {
    padding: 8px 14px;
    font-size: 13px;
  }
}


/* ═══════════════════════════════════════════════════════════════
   BRAND MARK
   ═══════════════════════════════════════════════════════════════ */
.brand-mark {
  display: inline-block;
  flex-shrink: 0;
  transition: transform var(--dur) var(--ease);
  /* Glow violeta sutil para dar vida al ícono */
  filter: drop-shadow(0 2px 12px rgba(139, 92, 255, 0.28));
}

.brand-mark-sm { width: 28px; height: 28px; }
.brand-mark-md { width: 38px; height: 38px; }
.brand-mark-lg { width: 56px; height: 56px; }

a:hover > .brand-mark,
a:focus-visible > .brand-mark {
  transform: scale(1.05);
  filter: drop-shadow(0 4px 18px rgba(139, 92, 255, 0.5));
}

@media (prefers-reduced-motion: reduce) {
  .brand-mark { transition: none; }
  a:hover > .brand-mark { transform: none; }
}
/* ═══════════════════════════════════════════════════════════════
   FLASH · cerrar + salida
   ═══════════════════════════════════════════════════════════════ */
.flash {
  position: relative;
  padding-right: 44px;
}

.flash-close {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-full);
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.flash-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}
html[data-theme="dark"] .flash-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.flash.is-hiding {
  animation: flashOut 260ms var(--ease) forwards;
}
@keyframes flashOut {
  to {
    opacity: 0;
    transform: translateY(-6px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    border-width: 0;
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flash.is-hiding {
    animation-duration: 0.01ms;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TOOLTIP
   ═══════════════════════════════════════════════════════════════ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 6px 10px;
  background: var(--bg-elevated, #1f2126);
  color: var(--text-primary, #f5f3ee);
  font-family: var(--font-sans, inherit);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  border-radius: 8px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (hover: none) {
  [data-tooltip]::before {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-tooltip]::before {
    transition: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   NAV · transiciones globales
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .sidebar-link,
  .sidebar-link svg,
  .mobile-bottom-link,
  .mobile-bottom-link svg,
  .mobile-topbar-action {
    transition: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR · micro-interacción de click
   ═══════════════════════════════════════════════════════════════ */
.sidebar-link:active .sidebar-icon svg,
.sidebar-link:active > svg {
  transform: scale(0.92);
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-link:active .sidebar-icon svg,
  .sidebar-link:active > svg { transform: none; }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE BOTTOM BAR · micro-interacción
   ═══════════════════════════════════════════════════════════════ */
.mobile-bottom-link:active .mobile-bottom-icon svg,
.mobile-bottom-link:active > svg {
  transform: scale(0.92);
}

@media (prefers-reduced-motion: reduce) {
  .mobile-bottom-link:active .mobile-bottom-icon svg,
  .mobile-bottom-link:active > svg { transform: none; }
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR · Crear (dropdown)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-create {
  position: relative;
}

.sidebar-create-trigger {
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 12px var(--sp-3);   /* ← explícito, igual que .sidebar-link */
  margin: 0;                    /* ← anula margin por defecto del button */
  color: inherit;               /* ← hereda color del sidebar */
  font-size: inherit;           /* ← hereda tamaño */
  line-height: inherit;         /* ← hereda line-height */
  border-radius: var(--r-md);   /* ← mismo radio que los links */
}

.sidebar-create-panel {
  position: absolute;
  bottom: calc(100% + 6px);   /* ← 6px ARRIBA del botón */
  top: auto;                   /* ← anula cualquier top previo */
  left: 8px;
  right: 8px;
  min-width: 220px;
  padding: 6px;
  background: var(--bg-elevated, #1f2126);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: sidebarCreateIn 0.15s ease;
}
@keyframes sidebarCreateIn {
  from { opacity: 0; transform: translateY(4px); }   /* ← era -4px */
  to   { opacity: 1; transform: translateY(0); }
}
.sidebar-create-panel[hidden] { display: none; }

.sidebar-create-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease;
}
.sidebar-create-item:hover {
  background: var(--bg-hover);
}
.sidebar-create-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-secondary);
}
/* ═══════════════════════════════════════════════════════════════════
   AVATAR · Sistema global
   - .avatar → contenedor circular
   - .avatar--xs / sm / md / lg / xl → tamaños
   - .avatar-letter → fallback con inicial
   - .avatar-letter--1..5 → gradientes determinísticos
   ═══════════════════════════════════════════════════════════════════ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-elevated);
  flex-shrink: 0;
  text-decoration: none;
  color: #fff;
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1;
  user-select: none;
  transition: opacity 0.15s var(--ease);
}
a.avatar:hover { opacity: 0.88; }

.avatar > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Tamaños */
.avatar--xs { width: 24px; height: 24px; font-size: 10px; }
.avatar--sm { width: 32px; height: 32px; font-size: 12px; }
.avatar--md { width: 40px; height: 40px; font-size: 15px; }
.avatar--lg { width: 56px; height: 56px; font-size: 22px; }
.avatar--xl { width: 150px; height: 150px; font-size: 60px; }

@media (max-width: 768px) {
  .avatar--xl { width: 90px; height: 90px; font-size: 36px; }
}

/* Letra inicial */
.avatar-letter {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

/* Gradientes determinísticos (mismo user = mismo color siempre) */
.avatar-letter--1 { background: linear-gradient(135deg, #7c5cff, #a78bfa); }
.avatar-letter--2 { background: linear-gradient(135deg, #ff6ba8, #f472b6); }
.avatar-letter--3 { background: linear-gradient(135deg, #10b981, #34d399); }
.avatar-letter--4 { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.avatar-letter--5 { background: linear-gradient(135deg, #3b82f6, #60a5fa); }

/* ─── Sidebar · texto del logo ─── */
.sidebar-logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.45em;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ─── Mobile topbar · texto del logo ─── */
.mobile-topbar-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2em;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════
   BANNER · Verificación de email pendiente
   ═══════════════════════════════════════════════════════════════════ */
.verify-banner {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 12%, transparent),
    color-mix(in srgb, var(--secondary) 8%, transparent)
  );
  border-bottom: 1px solid var(--border-color-soft);
  padding: 12px 16px;
}

.verify-banner-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.verify-banner-icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

.verify-banner-text {
  flex: 1;
  color: var(--text-secondary);
  line-height: 1.4;
}

.verify-banner-text strong {
  color: var(--text-primary);
  font-weight: 700;
}

.verify-banner-form {
  margin: 0;
  flex-shrink: 0;
}

.verify-banner-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
  line-height: 1.2;
}

.verify-banner-btn:hover {
  background: var(--accent-hover);
}

.verify-banner-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .verify-banner-inner {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
  }
  .verify-banner-text {
    flex-basis: 100%;
    order: 2;
  }
  .verify-banner-icon {
    order: 1;
  }
  .verify-banner-form {
    order: 3;
    margin-left: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .verify-banner-btn {
    transition: none;
  }
}