:root {
  --bg: #020617;
  --bg-elevated: rgba(15, 23, 42, 0.96);
  --bg-soft: rgba(15, 23, 42, 0.9);
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --accent-strong: rgba(59, 130, 246, 0.4);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border-subtle: rgba(148, 163, 184, 0.3);
  --danger: #ef4444;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.55);
  --shadow-chip: 0 8px 18px rgba(15, 23, 42, 0.9);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 55%),
    radial-gradient(circle at bottom right, rgba(236, 72, 153, 0.1), transparent 55%),
    #020617;
  color: var(--text);
}

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  backdrop-filter: blur(18px);
  background: linear-gradient(
    to right,
    rgba(15, 23, 42, 0.98),
    rgba(15, 23, 42, 0.94)
  );
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 32%;
  background: conic-gradient(
    from 160deg,
    #3b82f6,
    #8b5cf6,
    #ec4899,
    #3b82f6
  );
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #f9fafb;
  font-size: 1rem;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.6);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 650;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--muted);
}

.top-stats {
  display: none;
}

@media (min-width: 768px) {
  .top-stats {
    display: flex;
    gap: 10px;
  }

  .badge-stat {
    padding: 6px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(148, 163, 184, 0.35);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
    background: radial-gradient(circle at top left, #111827, #020617);
  }

  .badge-stat-label {
    color: var(--muted);
  }

  .badge-stat-value {
    font-weight: 600;
  }
}

/* Layout principal */

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 768px) {
  .main {
    padding: 16px 18px 24px;
    gap: 18px;
  }
}

/* Controles */

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: radial-gradient(circle at top left, #111827, #020617);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: var(--shadow-soft);
}

.search-wrapper {
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: rgba(15, 23, 42, 0.96);
  color: var(--text);
  font-size: 0.9rem;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-strong);
}

.controls-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 768px) {
  .controls-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* Chips de categorías */

.chip-row {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 2px;
}

.chip-row::-webkit-scrollbar {
  height: 4px;
}
.chip-row::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
}

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148, 163, 184, 0.45);
  font-size: 0.78rem;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.96);
  cursor: pointer;
  box-shadow: var(--shadow-chip);
  transition:
    background 0.18s ease,
    transform 0.12s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.chip-active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.65);
}

.chip-count {
  font-size: 0.72rem;
  opacity: 0.85;
}

/* Selector de orden */

.sort-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.sort-wrapper select {
  padding: 6px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.96);
  color: var(--text);
  font-size: 0.8rem;
}

.sort-wrapper select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Secciones */

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.section-title {
  font-size: 0.98rem;
  font-weight: 600;
}

.section-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Favoritas */

.favorites-section {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at top left, rgba(250, 204, 21, 0.1), #020617);
  border: 1px solid rgba(250, 204, 21, 0.7);
  box-shadow: var(--shadow-soft);
}

.favorites-section.visible {
  display: flex;
}

.favorites-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.favorites-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.favorites-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
}

.favorites-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 600px) {
  .favorites-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Grid de apps */

.apps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 600px) {
  .apps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .apps-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Tarjetas */

.app-card {
  position: relative;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at top left, #0f172a, #020617);
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 10px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
  transition:
    transform 0.14s ease,
    box-shadow 0.14s ease,
    border-color 0.14s ease;
}

.app-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.9);
  border-color: var(--accent-strong);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: radial-gradient(circle at top left, #3b82f6, #1f2937);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.app-category {
  font-size: 0.76rem;
  color: var(--muted);
}

.app-description {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
  flex: 1;
}

.app-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.app-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: var(--muted);
}

/* Pie de tarjeta */

.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.app-open-btn {
  border-radius: var(--radius-pill);
  border: none;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  background: linear-gradient(to right, #2563eb, #1d4ed8);
  color: white;
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-open-btn span {
  font-size: 0.9rem;
}

.app-open-btn:active {
  transform: translateY(1px);
}

.app-fav-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-fav-btn.fav {
  border-color: rgba(250, 204, 21, 0.9);
  color: #facc15;
}

/* Mensajes vacíos */

.empty-message {
  opacity: 0.8;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Footer */

.footer {
  padding: 8px 10px 14px;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  opacity: 0.85;
}
