:root {
  --ink-950: #10202b;
  --ink-900: #173040;
  --ink-800: #27495c;
  --ink-700: #45667a;
  --ink-600: #658698;
  --paper-0: #fffdfa;
  --paper-50: #f7f2ea;
  --paper-100: #efe5d6;
  --line: rgba(16, 32, 43, 0.12);
  --line-strong: rgba(16, 32, 43, 0.2);
  --panel: rgba(255, 253, 250, 0.97);
  --panel-dark: rgba(16, 32, 43, 0.9);
  --accent: #dc6b2d;
  --accent-strong: #a94d1f;
  --accent-soft: rgba(220, 107, 45, 0.12);
  --good: #2a7c59;
  --warn: #a06b1b;
  --shadow-xl: 0 28px 60px rgba(10, 21, 28, 0.2);
  --shadow-lg: 0 16px 34px rgba(10, 21, 28, 0.14);
  --shadow-md: 0 8px 18px rgba(10, 21, 28, 0.1);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --font-ui: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-display: "Baskerville", "Iowan Old Style", "Palatino Linotype", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 34%),
    linear-gradient(180deg, #f7f2e8 0%, #ebdfcd 100%);
  color: var(--ink-950);
  font-family: var(--font-ui);
}

body {
  overflow: hidden;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(16, 32, 43, 0.16) 0%, rgba(16, 32, 43, 0.05) 14%, transparent 24%),
    linear-gradient(0deg, rgba(16, 32, 43, 0.24) 0%, rgba(16, 32, 43, 0.08) 14%, transparent 30%);
  z-index: 5;
}

.map {
  width: 100%;
  height: 100%;
}

.topbar,
.search-panel,
.floor-dock,
.detail-card,
.sheet-card {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel);
  color: var(--ink-950);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  z-index: 20;
  transition:
    padding 160ms ease,
    gap 160ms ease,
    border-radius 160ms ease;
}

.brand-block {
  min-width: 0;
}

.topbar-summary {
  font-family: var(--font-display);
  max-width: 12rem;
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eyebrow {
  display: inline-block;
  color: var(--ink-600);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-block h1,
.sheet-header h2 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.12rem, 2.6vw, 1.38rem);
  line-height: 1.02;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.topbar-copy {
  margin: 5px 0 0;
  max-width: 26rem;
  color: var(--ink-700);
  font-size: 0.82rem;
  line-height: 1.3;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar.collapsed {
  left: auto;
  width: fit-content;
  max-width: calc(100vw - 28px);
  grid-template-columns: auto auto;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 22px;
}

.topbar.collapsed .eyebrow,
.topbar.collapsed .brand-block h1,
.topbar.collapsed .topbar-copy {
  display: none;
}

.topbar.collapsed .primary-button,
.topbar.collapsed .ghost-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.topbar.collapsed .topbar-actions {
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.topbar.collapsed #toggleOverlayButton,
.topbar.collapsed #locateButton,
.topbar.collapsed #switchVenueButton {
  display: none;
}

.topbar.collapsed .icon-button {
  min-width: 34px;
  padding: 0;
}

.primary-button,
.ghost-button,
.chip,
.floor-button,
.result-item,
.venue-option,
.clear-button {
  appearance: none;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
}

.primary-button,
.ghost-button,
.floor-button,
.venue-option,
.chip {
  cursor: pointer;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: var(--radius-pill);
  font-weight: 650;
  letter-spacing: -0.01em;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

.icon-button {
  min-width: 40px;
  padding-inline: 0;
  justify-content: center;
  text-align: center;
}

.ghost-button {
  background: rgba(16, 32, 43, 0.04);
  color: var(--ink-900);
  border: 1px solid rgba(16, 32, 43, 0.1);
}

.ghost-button:hover,
.ghost-button:focus-visible {
  background: rgba(16, 32, 43, 0.08);
  transform: translateY(-1px);
}

.ghost-button.active-location {
  background: rgba(27, 111, 180, 0.12);
  color: #14537f;
  border-color: rgba(27, 111, 180, 0.22);
}

.ghost-button.active-location:hover,
.ghost-button.active-location:focus-visible {
  background: rgba(27, 111, 180, 0.18);
}

.artwork-button::before {
  content: "";
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.locate-artwork::before {
  background-image: url("./assets/icons/curloc.png");
}

.ghost-button.compact {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 0.8rem;
}

.primary-button {
  background: var(--accent);
  color: #fff7f1;
  border: 1px solid transparent;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.search-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: min(62vh, 640px);
  max-height: min(62vh, 640px);
  padding: 10px 14px calc(max(14px, env(safe-area-inset-bottom)));
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -14px 30px rgba(10, 21, 28, 0.12);
  overflow: hidden;
  z-index: 20;
}

.search-panel.collapsed {
  gap: 0;
  height: auto;
  max-height: none;
  padding-top: 8px;
}

.panel-toggle {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.panel-handle {
  width: 56px;
  height: 5px;
  margin: 0;
  border-radius: var(--radius-pill);
  background: rgba(16, 32, 43, 0.14);
}

.panel-summary {
  display: none;
  min-width: 0;
  color: var(--ink-900);
  font-size: 0.94rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.panel-toggle-icon {
  color: var(--ink-700);
  font-size: 1rem;
  line-height: 1;
  transition: transform 160ms ease;
}

.search-panel.collapsed .panel-summary {
  display: block;
}

.search-panel.collapsed .panel-toggle-icon {
  transform: rotate(180deg);
}

.search-panel-content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.search-panel.collapsed .search-panel-content {
  display: none;
}

.panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.panel-header-copy {
  min-width: 0;
}

.venue-name {
  font-family: var(--font-display);
  font-size: 1.42rem;
  font-weight: 700;
  line-height: 1.02;
}

.venue-meta {
  margin-top: 6px;
  color: var(--ink-700);
  font-size: 0.87rem;
  line-height: 1.36;
}

.venue-meta:empty {
  display: none;
}

.venue-action-bar {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(min(62vh, 640px) + 14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid rgba(16, 32, 43, 0.18);
  background: rgba(16, 32, 43, 0.92);
  color: #fff7f1;
  box-shadow: var(--shadow-lg);
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
  z-index: 19;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

.venue-action-bar:hover,
.venue-action-bar:focus-visible {
  background: rgba(23, 48, 64, 0.95);
  transform: translateY(-1px);
}

.search-panel.collapsed ~ .venue-action-bar {
  bottom: calc(env(safe-area-inset-bottom) + 76px);
}

.search-box {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid rgba(16, 32, 43, 0.14);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.search-icon {
  color: var(--ink-700);
  font-size: 0.98rem;
}

.search-box input {
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink-950);
  font: inherit;
  font-size: 1rem;
}

.search-box input::placeholder {
  color: rgba(39, 73, 92, 0.52);
}

.clear-button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  color: var(--ink-700);
  cursor: pointer;
}

.clear-button:hover,
.clear-button:focus-visible {
  background: rgba(16, 32, 43, 0.06);
}

.status-banner {
  min-height: 18px;
  padding: 0 2px;
  color: var(--ink-700);
  font-size: 0.84rem;
}

.status-banner.good {
  color: var(--good);
}

.status-banner.warn {
  color: var(--warn);
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(220, 107, 45, 0.12);
  font-weight: 650;
  font-size: 0.88rem;
  text-align: left;
}

.chip:hover,
.chip:focus-visible {
  background: rgba(220, 107, 45, 0.18);
}

.chip-grid .chip {
  width: auto;
}

.chip.subtle {
  background: rgba(16, 32, 43, 0.05);
  color: var(--ink-800);
  border: 1px solid rgba(16, 32, 43, 0.06);
}

.results-section {
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.results-meta {
  min-height: 18px;
  padding: 0 2px;
  color: var(--ink-600);
  font-size: 0.82rem;
}

.results-meta:empty {
  display: none;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border-radius: 18px;
  text-align: left;
  background: #ffffff;
  border: 1px solid rgba(16, 32, 43, 0.08);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.result-item:hover,
.result-item:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(220, 107, 45, 0.22);
  box-shadow: 0 14px 26px rgba(10, 21, 28, 0.12);
}

.result-item.active {
  background: linear-gradient(180deg, #fff9f4 0%, #fffefc 100%);
  border-color: rgba(220, 107, 45, 0.3);
  box-shadow: 0 16px 28px rgba(10, 21, 28, 0.12);
}

.result-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.result-secondary {
  margin-top: 4px;
  color: var(--ink-700);
  font-size: 0.88rem;
}

.result-badge {
  padding: 7px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-badge.placed {
  background: rgba(42, 124, 89, 0.12);
  color: var(--good);
}

.result-badge.pending {
  background: rgba(160, 107, 27, 0.12);
  color: var(--warn);
}

.floor-dock {
  position: absolute;
  right: 12px;
  top: calc(max(14px, env(safe-area-inset-top)) + 98px);
  padding: 10px 8px;
  background: rgba(255, 253, 250, 0.9);
  border: 1px solid rgba(16, 32, 43, 0.1);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  z-index: 18;
}

.floor-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.floor-button {
  min-width: 48px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(16, 32, 43, 0.08);
  color: var(--ink-900);
  font-weight: 750;
  box-shadow: 0 6px 16px rgba(10, 21, 28, 0.08);
}

.floor-button.active {
  background: var(--ink-950);
  color: #fff7f1;
  border-color: transparent;
}

.detail-card {
  position: absolute;
  left: 14px;
  right: 78px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 360px);
  padding: 14px 16px;
  background: rgba(16, 32, 43, 0.92);
  color: #f7f7f4;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  z-index: 18;
}

.search-panel.collapsed ~ .detail-card {
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 88px);
}

.detail-title {
  font-size: 0.98rem;
  font-weight: 700;
}

.detail-copy {
  margin-top: 6px;
  color: rgba(247, 247, 244, 0.78);
  font-size: 0.88rem;
  line-height: 1.42;
}

.detail-link {
  display: inline-block;
  margin-top: 10px;
  color: #ffd4b7;
  font-weight: 650;
  text-decoration: none;
}

.session-tools {
  border-top: 1px solid rgba(16, 32, 43, 0.08);
  padding-top: 8px;
}

.session-tools summary {
  cursor: pointer;
  color: var(--ink-700);
  font-size: 0.82rem;
  font-weight: 650;
  list-style: none;
}

.session-tools summary::-webkit-details-marker {
  display: none;
}

.analytics-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
}

.analytics-summary {
  color: var(--ink-700);
  font-size: 0.8rem;
}

.analytics-actions {
  display: flex;
  gap: 8px;
}

.sheet {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 14px;
  background: rgba(10, 21, 28, 0.34);
  z-index: 30;
}

.sheet-card {
  width: min(560px, 100%);
  max-height: min(82vh, 720px);
  overflow: auto;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.venue-list {
  display: grid;
  gap: 10px;
}

.venue-option {
  width: 100%;
  padding: 16px;
  text-align: left;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid rgba(16, 32, 43, 0.08);
  box-shadow: var(--shadow-md);
}

.venue-option:hover,
.venue-option:focus-visible {
  border-color: rgba(220, 107, 45, 0.22);
}

.venue-option-title {
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 700;
}

.venue-option-copy {
  margin-top: 6px;
  color: var(--ink-700);
  font-size: 0.9rem;
  line-height: 1.38;
}

.empty-state {
  padding: 16px;
  border-radius: 18px;
  background: rgba(16, 32, 43, 0.04);
  color: var(--ink-700);
  line-height: 1.42;
}

.debug-panel {
  position: absolute;
  left: 14px;
  right: 14px;
  top: calc(max(14px, env(safe-area-inset-top)) + 90px);
  z-index: 40;
  max-height: 28vh;
  overflow: auto;
  padding: 10px 12px;
  background: rgba(9, 18, 24, 0.94);
  color: #d7f4dd;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  font-size: 0.8rem;
  line-height: 1.42;
}

.debug-panel summary {
  cursor: pointer;
  color: #fff7ef;
  font-weight: 700;
}

.debug-panel pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .primary-button,
  .ghost-button {
    flex: 1 1 0;
    justify-content: center;
    text-align: center;
  }

  .analytics-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .chip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-card {
    right: 14px;
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 388px);
  }

  .floor-dock {
    top: calc(max(14px, env(safe-area-inset-top)) + 142px);
  }
}

@media (max-width: 560px) {
  .topbar,
  .sheet-card {
    border-radius: 24px;
  }

  .topbar {
    padding: 11px 12px;
  }

  .topbar-copy {
    display: none;
  }

  .topbar-summary {
    max-width: 8.5rem;
    font-size: 0.9rem;
  }

  .topbar.collapsed {
    padding: 6px 9px;
    border-radius: 20px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar.collapsed .topbar-actions {
    display: flex;
  }

  .search-panel {
    height: min(68vh, 700px);
    max-height: min(68vh, 700px);
    padding: 10px 12px calc(max(12px, env(safe-area-inset-bottom)));
  }

  .search-panel:not(.collapsed) ~ .venue-action-bar {
    bottom: calc(min(68vh, 700px) + 10px);
  }

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

  .result-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .result-badge {
    justify-self: start;
  }

  .floor-dock {
    right: 10px;
    padding: 8px 7px;
  }

  .debug-panel {
    top: calc(max(14px, env(safe-area-inset-top)) + 126px);
  }
}
