:root {
  --bg: #0d0f12;
  --surface: #161a20;
  --surface-2: #1e232b;
  --border: #2a313c;
  --text: #e8eaed;
  --text-muted: #8b939e;
  --accent: #e6392e;
  --accent-hover: #ff4d42;
  --accent-dim: rgba(230, 57, 46, 0.15);
  --success: #3dd68c;
  --radius: 10px;
  --font-display: "Barlow Condensed", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --header-height: 4.75rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

body.filters-open {
  overflow: hidden;
}

.hide-mobile {
  display: revert;
}

.hide-desktop {
  display: none !important;
}

.header {
  position: relative;
  z-index: 200;
  overflow: visible;
  isolation: isolate;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #12151a 0%, var(--bg) 100%);
}

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

.brand {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
}

.sync-pill {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#user-greeting {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.account-menu {
  display: inline-block;
  max-width: 16rem;
}

.account-menu-summary {
  list-style: none;
  cursor: pointer;
}

.account-menu-summary::-webkit-details-marker,
.account-menu-summary::marker {
  display: none;
  content: "";
}

.account-menu-caret {
  margin-left: 0.2rem;
  font-size: 0.7rem;
}

.account-menu-list {
  margin-top: 0.35rem;
  min-width: 12.5rem;
  padding: 0.35rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.account-menu-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  text-decoration: none;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

.account-menu-item:hover,
.account-menu-item:focus {
  background: var(--surface-2);
  outline: none;
}

.hash-panel {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem 0;
}

.hash-panel:target {
  display: block;
}

.hash-panel h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-bottom: 0.35rem;
}

.hash-panel p {
  color: var(--text-muted);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--accent);
  letter-spacing: -0.05em;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.hero {
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.hero-sub {
  color: var(--text-muted);
  margin-top: 0.5rem;
  max-width: 560px;
}

.location-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-top: 1.5rem;
}

.location-input-group {
  flex: 1;
  min-width: 240px;
}

.location-input-group label,
.filter-group > label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-icon {
  min-width: 44px;
  padding: 0.65rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--text-muted);
}

.btn-full {
  width: 100%;
  margin-top: 0.5rem;
}

.status-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.status-text.error {
  color: #f87171;
}

.filter-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.35rem 0 0;
  line-height: 1.35;
}

.filter-prominent {
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
  align-items: start;
}

.main-content {
  min-width: 0;
}

.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.filters-scroll {
  padding-right: 0.15rem;
}

.filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.filters h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

.filter-count {
  color: var(--accent);
  margin-left: 0.35rem;
}

.filters-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
}

.mobile-toolbar {
  margin-bottom: 1rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom, 0));
  z-index: 80;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.45rem 0.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  min-height: 52px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.install-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(4.5rem + env(safe-area-inset-bottom, 0));
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  z-index: 85;
  font-size: 0.8rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.install-banner p {
  margin: 0;
  line-height: 1.35;
}

.filter-group {
  margin-bottom: 1.25rem;
}

.filter-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  margin-bottom: 0.4rem;
  text-align: left;
}

.filter-toggle:hover {
  color: var(--text);
}

.filter-toggle-icon {
  font-size: 0.85rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.filter-toggle[aria-expanded="false"] .filter-toggle-icon {
  transform: rotate(-90deg);
}

.filter-collapse-panel.collapsed {
  display: none;
}

.filter-collapsible .checkbox-grid-scroll {
  max-height: none;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-value {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 6.25rem;
  text-align: right;
  white-space: nowrap;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.checkbox-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.checkbox-grid-scroll {
  max-height: 14rem;
  overflow-y: auto;
  padding-right: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.45rem 0.5rem;
}

.filter-collapsible .checkbox-grid-scroll {
  max-height: 14rem;
}

.filter-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  padding: 0.35rem 0.15rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.checkbox-item input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.checkbox-select-all {
  font-weight: 600;
  color: var(--text);
  padding: 0.35rem 0.15rem 0.45rem;
  margin: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

.checkbox-select-all span {
  letter-spacing: 0.01em;
}

.cost-row,
.date-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.cost-row > div,
.date-row > div {
  flex: 1;
}

.date-row input[type="date"] {
  width: 100%;
}

.cost-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.cost-sep {
  color: var(--text-muted);
  padding-bottom: 0.7rem;
}

.results-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.results-header-main {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.results-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.results-count {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

.sort-select {
  min-width: 11.5rem;
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  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='%238b939e' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
}

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

.results-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  transition: border-color 0.15s;
}

.event-card:hover {
  border-color: #3d4654;
}

.event-card-main h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0.35rem;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-type {
  background: var(--accent-dim);
  color: var(--accent);
}

.badge-org {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.event-venue {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.event-date {
  font-size: 0.875rem;
  margin-top: 0.35rem;
}

.event-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.45;
}

.event-card-side {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  min-width: 130px;
}

.event-distance {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.event-distance span {
  font-size: 0.85rem;
  font-weight: 600;
}

.event-cost {
  font-weight: 600;
  font-size: 1.1rem;
}

.event-price-tiers {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-muted);
  text-align: right;
}

.price-tier {
  white-space: nowrap;
}

.price-tier-common {
  color: var(--text);
  font-weight: 600;
}

.price-tbd {
  color: var(--text-muted);
  font-style: italic;
}

.event-spots {
  font-size: 0.75rem;
  color: var(--success);
}

.event-spots.low {
  color: #fbbf24;
}

.event-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.25rem;
  padding: 0.45rem 0.85rem;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.event-link:hover {
  background: var(--accent);
  color: #fff;
}

.event-source {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.save-btn {
  margin-top: 0.25rem;
  padding: 0.45rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.save-btn.saved {
  border-color: var(--success);
  color: var(--success);
}

.save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-dialog {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 1.5rem;
  width: min(400px, 92vw);
}

.dialog-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.dialog-copy {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.auth-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.dialog-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.auth-tab {
  flex: 1;
  padding: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
}

.auth-tab.active {
  color: var(--accent);
  border-color: var(--accent);
}

.auth-form label {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.auth-form input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
}

.form-error {
  color: #f87171;
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}

.empty-state,
.loading-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-links {
  margin-top: 0.4rem;
}

.footer-links a {
  color: var(--text-muted);
}

.legal-page {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.legal-page h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin: 1rem 0 0.5rem;
}

.legal-page h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 1.5rem 0 0.5rem;
}

.legal-page p,
.legal-page li {
  color: var(--text-muted);
}

.legal-page ul {
  padding-left: 1.25rem;
  margin: 0.5rem 0 1rem;
}

.legal-page a {
  color: var(--accent);
}

@media (min-width: 861px) {
  .filters {
    position: sticky;
    top: 1rem;
    align-self: start;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .filters::-webkit-scrollbar {
    width: 6px;
  }

  .filters::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
  }
}

@media (max-width: 860px) {
  .hide-mobile {
    display: none !important;
  }

  .bottom-nav.hide-desktop {
    display: flex !important;
  }

  .mobile-toolbar.hide-desktop {
    display: block !important;
  }

  .install-banner.hide-desktop {
    display: flex !important;
  }

  #filters-close.hide-desktop {
    display: inline-flex !important;
  }

  .filters-backdrop.hide-desktop:not([hidden]) {
    display: block !important;
  }

  .header-inner {
    padding: 0.85rem 1rem;
    padding-top: calc(0.85rem + env(safe-area-inset-top, 0));
  }

  .logo-text {
    font-size: 1.45rem;
  }

  .main {
    padding: 1.25rem 1rem 5.5rem;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .main-content {
    grid-row: 1;
  }

  .filters {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 92vw);
    z-index: 100;
    border-radius: 0;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0));
  }

  .filters-scroll {
    padding-bottom: 0.5rem;
  }

  .filters.open {
    transform: translateX(0);
  }

  .location-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-search {
    width: 100%;
  }

  .input-row {
    flex-direction: row;
  }

  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  .sort-select {
    font-size: 16px;
  }

  .sort-control {
    width: 100%;
  }

  .sort-select {
    flex: 1;
    min-width: 0;
  }

  .event-card {
    grid-template-columns: 1fr;
  }

  .event-card-side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    text-align: left;
    gap: 0.65rem;
  }

  .event-link,
  .save-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .auth-dialog {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0));
  }
}