:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #6f706f;
  --line: #e7e6e2;
  --soft: #f1f1ee;
  --accent: #20211f;
  --accent-contrast: #ffffff;
  --shadow: 0 10px 28px rgba(25, 27, 26, .10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }

.topbar {
  height: 68px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(320px, 620px) minmax(52px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 10px 20px;
  background: rgba(247,247,245,.94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.brand {
  width: max-content;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent);
  color: white;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -.05em;
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy strong { font-size: 16px; letter-spacing: -.02em; }
.brand-copy small { color: var(--muted); font-size: 10px; margin-top: 4px; }
.search-wrap {
  height: 44px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  box-shadow: 0 2px 10px rgba(25,27,26,.04);
}
.search-wrap:focus-within { border-color: #b8b8b3; box-shadow: 0 0 0 3px rgba(0,0,0,.035); }
.search-wrap svg, .icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.search-wrap svg { color: var(--muted); flex: none; }
.search-wrap input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-wrap input::placeholder { color: #9a9b98; }
.icon-btn {
  justify-self: end;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: white;
  display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn:hover { background: var(--soft); }

.filterbar {
  height: 54px;
  background: rgba(247,247,245,.96);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 18;
  display: flex;
  align-items: center;
}
.filter-scroll {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 7px 20px;
}
.filter-scroll::-webkit-scrollbar { display: none; }
.segmented { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: white; flex: none; }
.seg, .filter-chip {
  border: 0;
  white-space: nowrap;
  cursor: pointer;
  transition: .16s ease;
}
.seg { background: transparent; border-radius: 999px; padding: 7px 12px; font-size: 13px; color: var(--muted); }
.seg:hover { color: var(--ink); }
.seg.active { background: var(--accent); color: var(--accent-contrast); }
.divider { width: 1px; height: 25px; background: var(--line); flex: none; margin: 0 3px; }
.filter-chip { height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: white; font-size: 13px; }
.filter-chip:hover { border-color: #c9c9c4; }
.filter-chip.active { background: #e9e9e4; border-color: #bdbdb7; font-weight: 650; }

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  display: grid;
  grid-template-columns: 390px 1fr;
  position: relative;
}
.results-panel {
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 8;
  transition: width .2s ease, transform .2s ease;
}
.results-panel.collapsed { width: 0; overflow: hidden; border: 0; transform: translateX(-100%); }
.workspace.list-collapsed { grid-template-columns: 0 1fr; }
.panel-head {
  min-height: 72px;
  padding: 16px 14px 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
}
.result-title { font-weight: 750; letter-spacing: -.02em; }
.result-meta { margin-top: 4px; font-size: 12px; color: var(--muted); }
.quiet-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
}
.results {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 10px 26px;
}
.venue-card {
  border-bottom: 1px solid var(--line);
  padding: 4px 0 7px;
}
.venue-card.selected { background: #fafaf8; border-radius: 14px; border-bottom-color: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.venue-summary {
  width: 100%;
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 9px;
  align-items: center;
  text-align: left;
  padding: 10px 9px 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.venue-dot { width: 8px; height: 8px; border-radius: 50%; background: #262826; box-shadow: 0 0 0 3px #eeeeea; }
.venue-text { min-width: 0; }
.venue-name { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.venue-location { display: block; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.venue-count { min-width: 27px; height: 23px; padding: 0 7px; display: grid; place-items: center; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 700; }
.venue-events { padding: 0 6px 4px 29px; }
.event-row {
  display: grid;
  grid-template-columns: 46px 1fr 18px;
  gap: 8px;
  padding: 8px 4px;
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
}
.event-row:hover { background: var(--soft); }
.event-time { font-size: 11px; color: var(--muted); padding-top: 2px; font-variant-numeric: tabular-nums; }
.event-main { min-width: 0; }
.event-title { display: block; font-size: 12.5px; line-height: 1.25; font-weight: 650; }
.event-tags { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-arrow { color: #a1a19c; font-size: 11px; }
.empty-state { margin: auto; max-width: 260px; text-align: center; padding: 30px 18px; color: var(--muted); display: flex; flex-direction: column; gap: 7px; font-size: 12px; }
.empty-state strong { color: var(--ink); font-size: 14px; }
.empty-icon { font-size: 28px; color: #c3c3bd; }
.hidden { display: none !important; }

.map-shell { min-width: 0; position: relative; background: #eaeae6; }
#map { position: absolute; inset: 0; }
.maplibregl-ctrl-group { border-radius: 12px !important; box-shadow: 0 4px 16px rgba(0,0,0,.10) !important; overflow: hidden; }
.maplibregl-ctrl-attrib { font-size: 9px !important; }
.search-area {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  height: 38px;
  padding: 0 15px;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.map-status {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 5;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 4px 16px rgba(0,0,0,.07);
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 11px;
  color: var(--muted);
  backdrop-filter: blur(10px);
}
.map-list-toggle {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 5;
  border: 1px solid var(--line);
  background: white;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.mobile-sheet { display: none; }

@media (max-width: 840px) {
  .topbar {
    height: 58px;
    grid-template-columns: auto 1fr auto;
    padding: 8px 10px;
    gap: 8px;
  }
  .brand-copy { display: none; }
  .brand-mark { width: 38px; height: 38px; }
  .search-wrap { height: 40px; min-width: 0; padding: 0 12px; }
  .filterbar { height: 48px; }
  .filter-scroll { padding: 6px 10px; }
  .seg { padding: 6px 10px; }
  .filter-chip { height: 32px; }
  .workspace { flex: 1 1 auto; min-height: 0; height: auto; display: block; }
  .results-panel { display: none; }
  .map-shell { position: absolute; inset: 0; }
  .desktop-only { display: none !important; }
  .map-status { bottom: 150px; }
  .search-area { top: 10px; }
  .mobile-sheet {
    position: absolute;
    display: flex;
    flex-direction: column;
    z-index: 12;
    left: 8px; right: 8px; bottom: 8px;
    height: 138px;
    max-height: calc(100% - 18px);
    background: rgba(255,255,255,.97);
    border: 1px solid rgba(0,0,0,.06);
    box-shadow: 0 12px 40px rgba(0,0,0,.17);
    border-radius: 20px;
    overflow: hidden;
    transition: height .24s ease;
    backdrop-filter: blur(18px);
  }
  .mobile-sheet.expanded { height: min(68vh, 620px); }
  .sheet-handle { height: 24px; border: 0; background: transparent; cursor: pointer; flex: none; }
  .sheet-handle span { display: block; width: 36px; height: 4px; margin: 8px auto; border-radius: 999px; background: #d3d3cf; }
  .mobile-sheet-head { height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 10px 7px 10px; border-bottom: 1px solid var(--line); flex: none; }
  .mobile-sheet-head strong { font-size: 12px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-sheet-head .quiet-btn { width: 28px; height: 28px; border: 0; }
  .mobile-results { min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px 7px 18px; }
  .mobile-results .venue-card { padding-bottom: 4px; }
  .mobile-results .venue-events { display: none; }
  .mobile-sheet.expanded .mobile-results .venue-events { display: block; }
}

@media (max-width: 470px) {
  .segmented .seg[data-time="all"] { display: none; }
  .filter-chip[data-category="exhibition"], .filter-chip[data-category="market"] { display: none; }
}

/* v6 map stability and result interaction */
.event-row { cursor: pointer; }
.event-row:focus-visible { outline: 2px solid #20211f; outline-offset: -2px; }
.event-source-link {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  align-self: center;
  border-radius: 50%;
  text-decoration: none;
  color: #8b8c88;
  font-size: 12px;
}
.event-source-link:hover { background: #e6e6e1; color: #20211f; }
.reset-map {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 5;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 999px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}
.reset-map:hover { background: #f4f4f1; }
@media (max-width: 840px) {
  .reset-map { right: 10px; top: 58px; }
}

/* v8 advanced date search + mobile event detail */
.advanced-trigger.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.advanced-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 20px;
  width: min(360px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 18px 50px rgba(24,25,24,.16);
  backdrop-filter: blur(18px);
}
.advanced-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.advanced-head strong { font-size:14px; }
.advanced-head .quiet-btn { width:30px; height:30px; border:0; background:var(--soft); }
.date-fields { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.date-fields label { display:flex; flex-direction:column; gap:6px; min-width:0; }
.date-fields label span { font-size:11px; color:var(--muted); font-weight:650; }
.date-fields input {
  width:100%; height:40px; border:1px solid var(--line); border-radius:11px;
  background:#fff; color:var(--ink); padding:0 10px; outline:0;
}
.date-fields input:focus { border-color:#b8b8b3; box-shadow:0 0 0 3px rgba(0,0,0,.035); }
.advanced-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:14px; }
.primary-action, .secondary-action {
  height:36px; padding:0 14px; border-radius:999px; cursor:pointer; font-weight:700; font-size:12px;
}
.primary-action { border:1px solid var(--accent); background:var(--accent); color:#fff; }
.secondary-action { border:1px solid var(--line); background:#fff; color:var(--muted); }

.event-detail { padding: 12px 14px 22px; }
.event-detail-kicker { color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.08em; margin-bottom:7px; }
.event-detail-title { margin:0 0 16px; font-size:20px; line-height:1.18; letter-spacing:-.025em; }
.event-detail-info { display:grid; gap:11px; }
.event-detail-info > div { display:grid; grid-template-columns:58px 1fr; gap:9px; align-items:start; }
.event-detail-info span { color:var(--muted); font-size:10px; padding-top:2px; }
.event-detail-info strong { font-size:12px; line-height:1.4; font-weight:650; }
.event-detail-source {
  margin-top:18px; height:42px; display:flex; align-items:center; justify-content:center; gap:8px;
  border-radius:12px; background:var(--accent); color:#fff; text-decoration:none; font-size:12px; font-weight:750;
}
.event-detail-source:hover { opacity:.92; }

@media (max-width: 840px) {
  .advanced-panel { top: calc(100% + 6px); right:10px; left:10px; width:auto; }
  .event-detail { padding-top:10px; }
}
