:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1d23;
  --text-muted: #5b6270;
  --border: #e3e5e9;
  --accent: #c8102e;
  --chip-bg: #eceef1;
  --chip-bg-active: #1a1d23;
  --chip-text-active: #ffffff;
  --new-badge: #c8102e;

  --cat-exclusivos: #b8860b;
  --cat-paneles: #2563eb;
  --cat-firmas: #7c3aed;
  --cat-boletos: #0891b2;
  --cat-noticias: #16a34a;
  --cat-general: #6b7280;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #1a1d23;
    --text: #eef0f3;
    --text-muted: #9aa1ad;
    --border: #2a2e37;
    --accent: #ff4d5e;
    --chip-bg: #262a33;
    --chip-bg-active: #eef0f3;
    --chip-text-active: #0f1115;
    --new-badge: #ff4d5e;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: max(12px, env(safe-area-inset-top)) 16px 8px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.15rem;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

header h1 .badge-count {
  font-size: 0.7rem;
  background: var(--new-badge);
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 600;
}

.meta-line {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.search-box {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--text);
  font-size: 0.85rem;
  white-space: nowrap;
  border: none;
  cursor: pointer;
}
.chip.active {
  background: var(--chip-bg-active);
  color: var(--chip-text-active);
  font-weight: 600;
}
.chip .count {
  opacity: 0.65;
  margin-left: 4px;
}

main {
  padding: 12px 16px 32px;
  max-width: 720px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  overflow: hidden;
}

.card-thumb {
  display: block;
  width: calc(100% + 32px);
  margin: -14px -16px 12px;
  max-height: 220px;
  object-fit: cover;
  background: var(--chip-bg);
}

.card-quick-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.quick-chip {
  font-size: 0.76rem;
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.quick-chip-time { color: var(--accent); font-weight: 600; }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.card-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.fav-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}
.fav-btn.active {
  color: var(--accent);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 6px;
  line-height: 1.35;
}

.card-new-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--new-badge);
  margin-top: 6px;
}

.card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.category-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  border-radius: 999px;
  padding: 2px 9px;
  margin-bottom: 8px;
}
.category-pill.cat-exclusivos-y-ventas { background: var(--cat-exclusivos); }
.category-pill.cat-paneles-y-horarios { background: var(--cat-paneles); }
.category-pill.cat-firmas { background: var(--cat-firmas); }
.category-pill.cat-boletos-y-registro { background: var(--cat-boletos); }
.category-pill.cat-noticias-y-guias { background: var(--cat-noticias); }
.category-pill.cat-general { background: var(--cat-general); }

.card-excerpt {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.card-details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  display: none;
}
.card.expanded .card-details { display: block; }

.detail-row {
  margin-bottom: 10px;
}
.detail-row b { color: var(--text-muted); font-weight: 600; }

.schedule-item {
  background: var(--chip-bg);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.schedule-item-when {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 3px;
}
.schedule-item-desc {
  font-size: 0.85rem;
  line-height: 1.35;
}

/* Vista calendario */
.view-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.view-toggle button {
  flex: 1 1 45%;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  white-space: nowrap;
  cursor: pointer;
}
.view-toggle button.active {
  background: var(--chip-bg-active);
  color: var(--chip-text-active);
  font-weight: 600;
  border-color: transparent;
}

.day-group {
  margin-bottom: 18px;
}
.day-group-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 8px;
  position: sticky;
  top: 128px;
  background: var(--bg);
  padding: 4px 0;
}
.agenda-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.agenda-row-time {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
}
.agenda-row-location {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 8px;
}
.agenda-row-desc {
  font-size: 0.88rem;
  margin-top: 4px;
  line-height: 1.4;
}
.agenda-row-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
}
.agenda-row-cat {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.agenda-row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.product-vendor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Vista Mi Plan */
.planner-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.planner-item.conflict {
  border-color: var(--new-badge);
}
.planner-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.planner-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 4px 0;
}
.conflict-warning, .zone-change-warning {
  font-size: 0.76rem;
  border-radius: 8px;
  padding: 5px 8px;
  margin-bottom: 6px;
}
.conflict-warning {
  background: var(--chip-bg);
  color: var(--new-badge);
  border: 1px solid var(--new-badge);
}
.zone-change-warning {
  background: var(--chip-bg);
  color: var(--text-muted);
}

.map-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 12px 0 8px;
}
#planner-map {
  height: 320px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.tag-list span {
  background: var(--chip-bg);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.78rem;
}

.link-list a {
  display: block;
  color: var(--accent);
  font-size: 0.85rem;
  text-decoration: none;
  margin-top: 4px;
  word-break: break-word;
}
.link-list a:active { opacity: 0.7; }

.card-original-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.load-more, .refresh-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  margin-top: 8px;
  cursor: pointer;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 480px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.product-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--chip-bg);
}
.product-thumb-empty {
  display: flex;
}
.product-body {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.product-vendor {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.product-name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
}
.product-price {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}
.product-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state, .loading-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 16px;
  font-size: 0.9rem;
}
