/* === Theme: Clásico (default) === */
:root,
[data-theme="clasico"] {
  --primary: #381d92;
  --primary-dark: #1C0A63;
  --primary-container: #5b3cc4;
  --secondary: #674fa7;
  --tertiary: #7539a8;
  --bg: #F2F2FA;
  --fg: #0B0620;
  --white: #ffffff;
  --muted: #4a4a6a;
  --muted-light: #6b6b8a;
  --border: transparent;
  --tag-bg: #ebe8f4;
  --tag-color: #381d92;
  --surface: #F2F2FA;
  --surface-container: #e8e6f2;
  --surface-container-low: #edebf6;
  --surface-container-high: #dddbe8;
  --surface-container-highest: #d3d1de;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 999px;
  --cal-low: #f0edf8;
  --cal-med: #e0d9f0;
  --cal-high: #cfc4e8;
  --cal-max: #bfb0e0;
  --header-bg: rgba(242, 242, 250, 0.85);
  --nav-bg: rgba(242, 242, 250, 0.9);
  --logo-agenda: #c4403a;
  --logo-madrid: #0B0620;
}

/* === Theme: Madrid === */
[data-theme="madrid"] {
  --primary: #b30012;
  --primary-dark: #8a000e;
  --primary-container: #e1001a;
  --secondary: #674fa7;
  --tertiary: #7539a8;
  --bg: #fbf9f8;
  --fg: #1b1c1c;
  --white: #ffffff;
  --muted: #5e3f3b;
  --muted-light: #936e6a;
  --border: transparent;
  --tag-bg: #f1daff;
  --tag-color: #4a3088;
  --surface: #fbf9f8;
  --surface-container: #f0eded;
  --surface-container-low: #f6f3f2;
  --surface-container-high: #eae8e7;
  --surface-container-highest: #e4e2e1;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 999px;
  --cal-low: #fde8e8;
  --cal-med: #fcd0d0;
  --cal-high: #f9b4b4;
  --cal-max: #f49999;
  --header-bg: rgba(251, 249, 248, 0.85);
  --nav-bg: rgba(251, 249, 248, 0.9);
  --logo-agenda: #e1001a;
  --logo-madrid: #1b1c1c;
}

/* === Theme: Noche === */
[data-theme="noche"] {
  --primary: #e1001a;
  --primary-dark: #b30012;
  --primary-container: #ff4d4d;
  --secondary: #b99ffe;
  --tertiary: #dfb7ff;
  --bg: #121212;
  --fg: #e4e2e1;
  --white: #1e1e1e;
  --muted: #a09c9a;
  --muted-light: #787472;
  --border: transparent;
  --tag-bg: #2d2040;
  --tag-color: #cfbcff;
  --surface: #121212;
  --surface-container: #1e1e1e;
  --surface-container-low: #1a1a1a;
  --surface-container-high: #2a2a2a;
  --surface-container-highest: #333333;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 999px;
  --cal-low: #2a1a1a;
  --cal-med: #3d2020;
  --cal-high: #4d2828;
  --cal-max: #5e3030;
  --header-bg: rgba(18, 18, 18, 0.9);
  --nav-bg: rgba(18, 18, 18, 0.92);
  --logo-agenda: #ff4d4d;
  --logo-madrid: #e4e2e1;
}

.logo {
  text-decoration: none;
  font-weight: 700;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  letter-spacing: -0.03em;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-transform: uppercase;
}

.logo-agenda {
  color: var(--logo-agenda);
}

.logo-madrid {
  color: var(--logo-madrid);
  font-weight: 800;
}

.logo-img {
  height: 2.5rem;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overflow-y: scroll;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Header — glassmorphism */
header {
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--fg);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: none;
}

header[hidden] {
  display: none;
}

.header-inner {
  max-width: 70rem;
  margin: 0 auto;
  padding: 0.5rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Date nav */
.date-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
  flex: 1;
}

.date-nav button {
  background: none;
  border: none;
  color: var(--muted-light);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-nav button:hover {
  background: var(--surface-container);
  color: var(--fg);
}

.date-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
  background: var(--surface-container-low) !important;
  border: none !important;
  color: var(--fg) !important;
  padding: 0.4rem 0.8rem !important;
  border-radius: var(--radius-full) !important;
  cursor: pointer;
}

.date-label:hover {
  background: var(--surface-container) !important;
}

#current-date {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.event-count-badge {
  background: none;
  color: var(--muted);
  padding: 0;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.mobile-only { display: none; }


#date-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  top: 100%;
  left: 50%;
}

.header-nav {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  align-self: stretch;
  align-items: stretch;
}

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.search-bar input {
  flex: 1;
  background: var(--surface-container);
  border: 2px solid var(--primary);
  color: var(--fg);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}

.search-bar button {
  background: none;
  border: none;
  color: var(--muted-light);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius);
}

.search-bar button:hover {
  color: var(--fg);
}

.btn-search {
  background: none;
  border: none;
  color: var(--muted-light);
  cursor: pointer;
  padding: 0.3rem;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.btn-search:hover {
  color: var(--fg);
}

.search-date-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  padding: 0.8rem 0 0.3rem;
  border-bottom: 1px solid var(--surface-container);
  margin-bottom: 0.3rem;
}

.search-result-count {
  font-size: 0.82rem;
  color: var(--muted-light);
  margin: 0 0 0.3rem;
}

.view-toggle {
  background: var(--surface-container-low);
  border: none;
  color: var(--muted-light);
  padding: 0.4rem 1rem;
  border-radius: 0;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  align-self: stretch;
}


.view-toggle:first-child {
  border-radius: 4px 0 0 4px;
}

.view-toggle:nth-child(3) {
  border-radius: 0 4px 4px 0;
}


.view-toggle:hover {
  background: var(--surface-container);
  color: var(--fg);
}

.view-toggle.active {
  background: var(--primary);
  color: var(--white);
  position: relative;
  z-index: 1;
}

.view-toggle + .view-toggle {
  margin-left: -1px;
}

/* Filter bar */
.filter-bar {
  display: none;
}

.filter-bar-inner {
  max-width: 70rem;
  margin: 0 auto;
  display: flex;
  gap: 0.6rem;
  padding: 0.7rem 1.5rem;
  flex-wrap: wrap;
}

.search-input {
  padding: 0.45rem 0.8rem;
  border: none;
  border-radius: var(--radius-full);
  background: var(--surface-container-highest);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--fg);
  width: 12rem;
  transition: box-shadow 0.15s;
}

.search-input:focus {
  box-shadow: 0 0 0 2px rgba(179, 0, 18, 0.15);
  outline: none;
}

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

.filter-bar select {
  padding: 0.45rem 2rem 0.45rem 0.8rem;
  border: none;
  border-radius: var(--radius-full);
  background: var(--surface-container-highest);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235e3f3b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  transition: box-shadow 0.15s;
}

.filter-bar select:hover,
.filter-bar select:focus {
  box-shadow: 0 0 0 2px rgba(179, 0, 18, 0.15);
  outline: none;
}

.filter-bar select.active-filter {
  background: var(--primary);
  color: var(--white);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

/* Main content */
main {
  max-width: 70rem;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 50vh;
}

.swipe-hint { display: none; }

/* Event card — no borders, tonal layering */
.event-card {
  background: none;
  border-radius: 0;
  padding: 0.6rem 0.6rem;
  margin-bottom: 0;
  border: none;
  border-bottom: 1px solid var(--surface-container);
  transition: background 0.15s;
}

.event-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  cursor: pointer;
}

.event-card:hover {
  background: var(--surface-container-low);
}


.event-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.3;
}

.event-header .event-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-left: auto;
}

.event-time {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.event-with-thumb {
  display: flex;
  gap: 1rem;
  margin-left: -0.6rem;
}

.event-with-thumb .event-main {
  flex: 1;
  min-width: 0;
}

.event-thumb {
  width: 300px;
  object-fit: contain;
  flex-shrink: 0;
  align-self: center;
}

.event-title {
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 0.3rem;
}

.event-title a {
  color: var(--fg);
  text-decoration: none;
}

.event-title a:hover {
  color: var(--primary);
}

.event-location {
  font-size: 0.82rem;
  color: var(--muted-light);
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  min-width: 0;
  margin-top: 0.4rem;
}

.location-pin {
  font-size: 0.75rem;
  flex-shrink: 0;
}

.location-dist {
  color: var(--muted-light);
  opacity: 0.7;
  white-space: nowrap;
}

.location-clickable {
  cursor: pointer;
  border-radius: var(--radius-full);
  padding: 0.1rem 0.3rem;
  transition: background 0.15s, color 0.15s;
}

.location-clickable:hover {
  background: var(--surface-container);
  color: var(--primary);
}

.location-active {
  background: var(--surface-container);
  color: var(--primary);
}

.event-price {
  font-size: 0.82rem;
  color: var(--muted-light);
  white-space: nowrap;
}

.event-desc {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 0.5rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
}

.event-footer .event-location {
  margin-top: 0;
}

.event-footer .event-tags {
  margin-left: auto;
}

.event-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex-shrink: 0;
  margin-left: auto;
}

.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-color);
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
}

.tag-source {
  background: var(--surface-container-high);
  color: var(--muted-light);
}

.tag-clickable {
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tag-clickable:hover {
  background: var(--secondary);
  color: var(--white);
}

.tag-active {
  background: var(--secondary);
  color: var(--white);
  cursor: pointer;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;
}

.tag-dist, .tag-cat {
  background: var(--surface-container-low);
  color: var(--fg);
}

.tag-free {
  background: rgba(34,197,94,0.12);
  color: #16a34a;
  font-weight: 700;
}

.tag-price {
  background: var(--surface-container-high);
  color: var(--muted);
  font-weight: 600;
}

.tag-link {
  cursor: pointer;
}

.tag-link:hover {
  background: var(--surface-container-high);
}

/* Map */
#map-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: none;
}

body:not([data-view="list"]):not([data-view="user"]) footer { display: none; }

body[data-view="map"] #map-container {
  border-radius: 0;
  border: none;
  position: fixed;
  inset: 0;
  z-index: 10;
}

body[data-view="map"] #map {
  height: 100%;
}

body[data-view="map"] main {
  padding: 0;
}

#map {
  height: 70vh;
  width: 100%;
  background: var(--bg);
}

.map-cat-icon {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

.map-popup .popup-time {
  color: var(--muted-light);
  font-weight: 500;
}

.map-popup .popup-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.map-popup .popup-title a {
  color: var(--primary);
  text-decoration: none;
}

.map-popup .popup-title a:hover {
  text-decoration: underline;
}

.map-popup .popup-meta {
  font-size: 0.78rem;
  color: var(--muted-light);
  margin-bottom: 0.2rem;
}

.map-popup .popup-location {
  font-size: 0.78rem;
  color: var(--fg);
}

.map-popup .popup-tags {
  margin-top: 0.3rem;
}

.map-popup .tag {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
}

/* Calendar view */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
  max-width: 40rem;
  margin: 0 auto;
}

.cal-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-light);
  padding: 0.3rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  border: none;
  background: var(--white);
  position: relative;
}

.cal-cell:hover {
  box-shadow: 0 2px 12px rgba(179, 0, 18, 0.1);
}

.cal-empty {
  background: none;
  cursor: default;
  border: none;
}

.cal-empty:hover {
  box-shadow: none;
}

.cal-empty-day {
  opacity: 0.4;
}

.cal-day-num {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
}

.cal-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 0.1rem;
}

.cal-today {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.cal-today .cal-day-num {
  color: var(--primary);
}

.cal-selected {
  background: var(--primary);
}

.cal-selected .cal-day-num,
.cal-selected .cal-count {
  color: var(--white);
}

.cal-low {
  background: var(--cal-low);
}

.cal-med {
  background: var(--cal-med);
}

.cal-high {
  background: var(--cal-high);
}

.cal-max {
  background: var(--cal-max);
}

.cal-selected.cal-low,
.cal-selected.cal-med,
.cal-selected.cal-high,
.cal-selected.cal-max {
  background: var(--primary);
}

/* Flatpickr theme override */
.flatpickr-calendar {
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  border: none;
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.flatpickr-day.today {
  border-color: var(--primary);
}

.flatpickr-day.today:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-weekdays,
span.flatpickr-weekday {
  background: var(--primary);
  color: var(--white);
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  fill: var(--white);
  color: var(--white);
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
  fill: rgba(255, 255, 255, 0.7);
  color: rgba(255, 255, 255, 0.7);
}

.flatpickr-current-month input.cur-year {
  color: var(--white);
}

/* Header link */
.header-link {
  color: var(--muted-light);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-full);
  transition: color 0.15s, background 0.15s;
}

.header-link:hover {
  color: var(--fg);
  background: var(--surface-container);
}

/* Sync button */
.btn-sync {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  color: var(--muted-light);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  padding: 0.35rem 0.7rem;
  transition: all 0.15s;
}

.btn-sync:hover {
  background: var(--surface-container);
  color: var(--fg);
}

.btn-sync.logged-in {
  color: var(--fg);
}

.sync-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

/* Info page */
.info-page {
  max-width: 40rem;
  line-height: 1.7;
}

.info-page h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.info-page h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.info-page p {
  margin-bottom: 0.8rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.info-page ul {
  margin-bottom: 0.8rem;
  padding-left: 1.2rem;
}

.info-page li {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.info-page a {
  color: var(--primary);
  text-decoration: none;
}

.info-page a:hover {
  text-decoration: underline;
}

.info-back {
  margin-top: 2rem;
}

.active-filter-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  margin-bottom: 0.75rem;
  background: var(--surface-container-low);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 500;
}
.active-filter-banner button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted-light);
  font-size: 0.8rem;
  padding: 0 0.2rem;
  margin-left: auto;
}

/* Empty / loading state */
.empty-state {
  text-align: center;
  color: var(--muted-light);
  padding: 4rem 1rem;
  font-size: 0.95rem;
}

/* Footer */
footer {
  max-width: 70rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted-light);
  line-height: 1.6;
}

footer p + p {
  margin-top: 0.3rem;
}

/* Mobile */
/* Bottom nav — mobile only */
.bottom-nav {
  display: none;
}

@media (max-width: 640px) {
  /* Bottom tab bar — glassmorphism */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 150;
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: none;
    border-radius: 0 !important;
    box-shadow: 0 -2px 0 rgba(0,0,0,0.15);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  .bottom-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.55rem 0.25rem;
    background: none;
    border: none;
    color: var(--muted-light);
    font-family: inherit;
    font-size: 0.62rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-tab.active {
    color: var(--primary);
  }

  .bottom-tab svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }

  /* Header */
  .header-inner {
    padding: 0.45rem 0.9rem;
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  .logo {
    display: none;
  }

  .header-nav {
    display: none;
  }

  .date-nav {
    flex: 1;
    justify-content: space-between;
    position: relative;
  }

  .date-nav > #prev-day,
  .date-nav > #next-day {
    display: none;
  }

  .date-label {
    flex: 1;
    justify-content: space-between;
    padding: 0.5rem 0.2rem !important;
    background: none !important;
    border-radius: 0 !important;
  }

  #current-date {
    font-size: 1rem;
    font-weight: 700;
  }

  .event-count-badge {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
  }

  .mobile-only { display: none; }

  .btn-sync {
    display: none;
  }

  .header-link {
    display: none;
  }

  .filter-bar-inner {
    padding: 0.5rem 0.8rem;
    gap: 0.35rem;
    flex-wrap: nowrap;
  }

  .filter-bar select {
    font-size: 0.72rem;
    padding: 0.3rem 1.4rem 0.3rem 0.4rem;
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    background-position: right 0.3rem center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .active-filters:empty {
    display: none;
  }

  main {
    padding: 0.4rem 0 0;
    padding-bottom: calc(0.4rem + 58px + env(safe-area-inset-bottom, 0px));
  }

  body[data-view="user"] main {
    padding: 0;
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  }

  .event-card {
    background: var(--white);
    border-radius: 0;
    border-bottom: none;
    padding: 0;
    margin-bottom: 0.6rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }

  .event-card:hover {
    background: var(--white);
  }

  .event-thumb {
    width: 100%;
    height: 160px;
    object-fit: cover;
  }

  .event-mobile-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.9rem;
  }

  .event-mobile-top .event-tags {
    margin-top: 0;
  }

  .event-mobile-body {
    padding: 0.5rem 0.9rem 0.7rem;
  }

  .event-mobile-actions {
    display: flex;
    border-top: 1px solid var(--surface-container);
  }

  .ev-action-mobile {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.5rem;
    background: none;
    border: none;
    border-right: 1px solid var(--surface-container);
    color: var(--muted-light);
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .ev-action-mobile:last-child {
    border-right: none;
  }

  .ev-action-mobile.active {
    color: var(--primary);
  }

  .ev-action-mobile svg {
    flex-shrink: 0;
  }

  .event-mobile-body .event-location {
    flex: 1;
    min-width: 0;
    padding: 0;
  }

  .event-time {
    font-size: 0.9rem;
  }

  .event-title {
    font-size: 0.95rem;
    margin-top: 0.15rem;
  }

  .event-desc {
    margin-top: 0.3rem;
    font-size: 0.82rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .event-tags {
    margin-left: 0;
    margin-top: 0.3rem;
  }

  .active-filters {
    margin-left: 0;
    width: 100%;
  }

  .cal-grid {
    gap: 0.25rem;
  }

  .cal-day-num {
    font-size: 0.8rem;
  }

  .cal-count {
    font-size: 0.6rem;
  }

  .event-actions {
    display: none !important;
  }

  .event-card {
    position: relative;
  }

  .event-card .swipe-hint {
    display: none;
  }

  /* Map full-screen on mobile */
  body[data-view="map"] #map-container {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  }
}

/* Event action buttons */
.event-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
  margin-left: auto;
}

.ev-action {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: var(--radius);
  color: var(--muted-light);
  opacity: 0.3;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.ev-action:hover {
  opacity: 1;
  background: var(--surface-container);
}

.ev-action.active {
  opacity: 1;
}

.ev-fav.active {
  color: var(--primary-container);
}

.ev-seen.active {
  color: #16a34a;
}

.ev-dismiss:hover {
  color: var(--muted-light);
}

.event-card:hover .ev-action {
  opacity: 0.6;
}

.event-card:hover .ev-action.active {
  opacity: 1;
}

.event-card:hover .ev-action:hover {
  opacity: 1;
}

.popup-venue {
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  color: var(--muted-light);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.popup-event + .popup-event {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--surface-container-high);
}

.map-popup {
  max-height: 300px;
  overflow-y: auto;
}

/* Map popup actions */
.popup-actions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.4rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--surface-container-high);
}

.popup-actions .ev-action {
  opacity: 0.5;
}

.popup-actions .ev-action.active,
.popup-actions .ev-action:hover {
  opacity: 1;
}

.user-location {
  background: #4285f4;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.map-locate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: white;
  border: 2px solid rgba(0,0,0,0.2);
  border-radius: 4px;
  cursor: pointer;
  color: #333;
  padding: 0;
  box-shadow: none;
}
.map-locate-btn:hover {
  background: #f4f4f4;
}
.map-locate-btn svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 640px) {
  .leaflet-control-zoom,
  .map-locate-btn {
    display: none !important;
  }
}

/* User profile view — Stitch redesign */
.user-page {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Centered profile */
.user-profile-centered {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

.user-avatar-large {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  flex-shrink: 0;
}

.user-profile-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.user-name {
  font-weight: 700;
  font-size: 1.1rem;
}

.user-email {
  color: var(--muted-light);
  font-size: 0.82rem;
}

/* Stats row */
.user-stats {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.stat-card {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: end;
  gap: 0;
  padding: 0.75rem;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.stat-card:hover {
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
}

.stat-label {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.65rem;
  color: var(--muted-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  align-self: start;
}

.stat-num {
  grid-column: 1;
  grid-row: 2;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--fg);
}

.stat-icon {
  grid-column: 2;
  grid-row: 1 / 3;
  font-size: 1.1rem;
  opacity: 1;
  align-self: end;
}

/* Section containers */
.pref-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pref-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.78rem;
}

.pref-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Category grid — tile cards */
.cat-grid-circles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  padding: 0;
}

.cat-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: var(--surface-container-high);
  border: none;
  cursor: pointer;
  padding: 0.6rem 0.15rem;
  border-radius: var(--radius);
  transition: opacity 0.15s, background 0.15s;
}

.cat-circle:not(.active) {
  background: var(--surface-container-low);
}

.cat-circle.active {
  background: color-mix(in srgb, var(--primary-dark) 55%, var(--surface-container));
}

.cat-circle.active .cat-circle-label {
  color: var(--white);
}

.cat-circle-icon {
  font-size: 1.2rem;
  line-height: 1;
  background: none !important;
}

.cat-circle-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--fg);
  text-align: center;
  line-height: 1.1;
}

/* Preference card */
.pref-card {
  background: none;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Toggle row */
.setting-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--surface-container-low);
  border-radius: var(--radius-lg);
  gap: 1rem;
}

.setting-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.setting-toggle-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--fg);
}

.setting-toggle-hint {
  font-size: 0.75rem;
  color: var(--muted-light);
}

/* Setting grid (2-col dropdowns) */
.setting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.setting-grid-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.setting-grid-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-light);
}

/* Custom dropdown */
.custom-dropdown {
  position: relative;
  width: 100%;
}

.custom-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 0.85rem;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0.55rem 0.75rem;
  background: var(--surface-container-low);
  color: var(--fg);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.custom-dropdown-trigger:hover {
  background: var(--surface-container-high);
}

.custom-dropdown-trigger .dd-arrow {
  font-size: 0.6rem;
  opacity: 0.4;
  transition: transform 0.2s;
}

.custom-dropdown.open .dd-arrow {
  transform: rotate(180deg);
}

.custom-dropdown-menu {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  min-width: 100%;
  background: var(--surface-container);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  overflow: hidden;
  z-index: 100;
}

.custom-dropdown.open .custom-dropdown-menu {
  display: block;
}

.custom-dropdown-option {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--fg);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.15s;
}

.custom-dropdown-option:hover {
  background: var(--surface-container-high);
}

.custom-dropdown-option.selected {
  color: var(--primary);
  font-weight: 600;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-container-high);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.setting-hint {
  font-size: 0.78rem;
  color: var(--muted-light);
  margin-bottom: 0.75rem;
}

/* Map tile options */
.map-tile-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.map-tile-btn { padding: 0.4rem 1rem; border: none; border-radius: var(--radius-full); background: var(--surface-container-low); cursor: pointer; font-size: 0.875rem; transition: all 0.15s; }
.map-tile-btn.active { background: var(--primary); color: var(--white); font-weight: 600; }

/* Logout */
/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s;
}

.confirm-overlay.visible {
  opacity: 1;
}

.confirm-dialog {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  transform: scale(0.95);
  transition: transform 0.2s;
}

.confirm-overlay.visible .confirm-dialog {
  transform: scale(1);
}

.confirm-dialog p {
  font-size: 0.92rem;
  color: var(--fg);
  margin: 0 0 1.25rem;
  line-height: 1.4;
}

.confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.confirm-cancel,
.confirm-ok {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}

.confirm-cancel {
  background: var(--surface-container-high);
  color: var(--fg);
}

.confirm-cancel:hover {
  background: var(--surface-container-highest);
}

.confirm-ok {
  background: #dc2626;
  color: white;
}

.confirm-ok:hover {
  background: #b91c1c;
}

.pwa-install-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.2rem;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-lg);
  cursor: pointer;
  margin-bottom: 1rem;
  transition: opacity 0.15s;
}
.pwa-install-banner:hover { opacity: 0.9; }
.pwa-install-banner span:first-child { font-size: 1.5rem; }
.pwa-install-banner small { opacity: 0.8; }

.user-actions-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.btn-danger {
  border-color: var(--muted-light) !important;
  color: var(--muted-light) !important;
}

.btn-danger:hover {
  background: #dc2626 !important;
  border-color: #dc2626 !important;
  color: var(--white) !important;
}

.btn-logout {
  padding: 0.65rem 1.5rem;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-full);
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
  align-self: center;
}

.btn-logout:hover {
  background: var(--primary);
  color: var(--white);
}

/* Login */
.btn-login {
  width: 100%;
  padding: 0.75rem;
  border: none;
  color: var(--white);
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-container) 100%);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: opacity 0.15s;
}

.btn-login:hover {
  opacity: 0.9;
}


/* =====================
   SWIPE VIEW (Mix mode)
   ===================== */

/* Show swipe button only on mobile */
.view-toggle-swipe { display: none !important; }
@media (max-width: 640px) {
  .view-toggle-swipe { display: inline-flex !important; }
}

/* Swipe container — fullscreen overlay */
#swipe-container {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  padding: 0.5rem 0.75rem 0;
}
@media (max-width: 640px) {
  #swipe-container { padding-bottom: 60px; }
}
#swipe-container[hidden] { display: none; }

.swipe-deck {
  position: relative;
  width: 100%;
  max-width: 480px;
  flex: 1;
  min-height: 0;
  touch-action: none;
  margin: 0.5rem;
}

/* Cards */
.swipe-card {
  position: absolute;
  left: 0; right: 0;
  top: 0;
  bottom: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
  z-index: 2;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}

.swipe-card-top { z-index: 4; cursor: grab; }
.swipe-card-top:active { cursor: grabbing; }

/* Card background gradient */
.swipe-card-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.swipe-cat-badge {
  display: none;
}

.swipe-card-img {
  position: absolute;
  top: 2.5rem; left: 0; right: 0;
  width: 100%;
  height: calc(50% - 2.5rem);
  object-fit: contain;
  object-position: center center;
  pointer-events: none;
  background: #111;
}

.swipe-card--has-img {
  background: #111;
}

/* Large emoji centered in upper portion */
.swipe-emoji-area {
  position: absolute;
  top: 10%;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.swipe-emoji-big {
  font-size: 5rem;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.35));
  line-height: 1;
}

/* Bottom info overlay */
.swipe-info {
  position: absolute;
  top: 50%;
  bottom: 0; left: 0; right: 0;
  padding: 1rem 1rem 2.5rem;
  background: linear-gradient(to top, rgba(10,10,12,0.92) 0%, rgba(10,10,12,0.65) 55%, transparent 100%);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
}

.swipe-card--has-img .swipe-info {
  top: 50%;
  background: linear-gradient(to top, rgba(17,17,17,1) 0%, rgba(17,17,17,0.97) 70%, rgba(17,17,17,0.7) 90%, transparent 100%);
}

.swipe-info-badges {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  z-index: 5;
}

.swipe-info-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: rgba(59,130,246,0.8);
  color: white;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.swipe-info-badge-free { background: rgba(34,197,94,0.85); }

.swipe-counter {
  font-size: 0.75rem;
  opacity: 0.6;
  margin-bottom: 0.2rem;
  font-weight: 600;
}

.swipe-info-title {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.3rem;
}

.swipe-info-meta {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-bottom: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.swipe-info-desc {
  font-size: 0.8rem;
  line-height: 1.45;
  opacity: 0.7;
  margin-top: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: unset;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.swipe-info-link {
  position: absolute;
  bottom: 3.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.65rem 2rem;
  background: var(--primary);
  color: white;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-full);
  z-index: 4;
  white-space: nowrap;
}

/* Top bar: counter */
.bottom-tab.active {
  position: relative;
  overflow: hidden;
}

.bottom-tab.active::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 100%;
  background: var(--primary);
  opacity: 0.15;
  pointer-events: none;
  border-radius: 0;
}

/* Swipe direction overlays */
.swipe-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  opacity: 0;
  pointer-events: none;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: opacity 0.06s;
  border-radius: var(--radius-lg);
}

.swipe-overlay span:first-child { font-size: 3rem; }

.swipe-overlay-right {
  background: rgba(34,197,94,0.12);
  color: #22c55e;
  border: 3px solid #22c55e;
}
.swipe-overlay-left {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
  border: 3px solid #ef4444;
}
.swipe-overlay-up {
  background: rgba(59,130,246,0.12);
  color: #3b82f6;
  border: 3px solid #3b82f6;
}

/* Action buttons */
.swipe-actions-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3rem;
  margin-top: -32px;
  position: relative;
  z-index: 10;
  padding-bottom: 0.75rem;
}

.swipe-btn {
  border-radius: 50%;
  border: 2.5px solid;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: transform 0.1s, background 0.1s;
  -webkit-tap-highlight-color: transparent;
  width: 68px;
  height: 68px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.swipe-btn:active { transform: scale(0.87); }

.swipe-btn-dismiss { border-color: #ef4444; color: #ef4444; }
.swipe-btn-dismiss:hover { background: rgba(239,68,68,0.08); }

.swipe-btn-skip {
  border-color: var(--primary); color: var(--primary);
  width: 88px; height: 88px;
  position: relative;
  overflow: hidden;
}

.swipe-btn-skip::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: var(--skip-fill, 100%);
  background: var(--primary);
  opacity: 0.25;
  transition: height 0.3s ease;
  pointer-events: none;
}
.swipe-btn-skip:hover { background: rgba(59,130,246,0.08); }

.swipe-btn-fav { border-color: #22c55e; color: #22c55e; }
.swipe-btn-fav:hover { background: rgba(34,197,94,0.08); }

.swipe-back-btn { display: none; }

/* Empty state */
.swipe-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted-light);
}

.swipe-empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.swipe-empty-title { font-size: 1.1rem; font-weight: 700; color: var(--fg); margin-bottom: 0.4rem; }
.swipe-empty p { margin-bottom: 1.25rem; font-size: 0.85rem; }
.swipe-empty-actions {
  display: flex;
  gap: 0.75rem;
}
.swipe-empty button {
  background: var(--primary);
  color: var(--white);
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
