/* ==========================================================================
   Campus Map — styles
   ========================================================================== */

:root {
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;

  --bg: #e8efe6;
  --bg-elevated: #f7faf6;
  --surface: #ffffff;
  --text: #1a241c;
  --text-muted: #5a6b5e;
  --border: #c5d4c8;
  --accent: #1f6b4a;
  --accent-hover: #175539;
  --accent-soft: #d8ebe0;
  --danger: #b42318;
  --shadow: 0 8px 28px rgba(26, 36, 28, 0.14);
  --shadow-sm: 0 2px 10px rgba(26, 36, 28, 0.1);
  --focus: #1f6b4a;
  --header-h: 72px;
  --footer-h: 48px;
  --panel-w: min(380px, 92vw);
  --marker-size: 18px;
  --radius: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #121816;
  --bg-elevated: #1a221e;
  --surface: #222c27;
  --text: #e8f0ea;
  --text-muted: #9aada0;
  --border: #334038;
  --accent: #4ade80;
  --accent-hover: #86efac;
  --accent-soft: #1a3326;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --focus: #4ade80;
}

/* Reset / base ----------------------------------------------------------- */

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(ellipse 120% 80% at 10% -10%, #cfe0d4 0%, transparent 55%),
    radial-gradient(ellipse 90% 70% at 100% 0%, #d4cfc0 0%, transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 120% 80% at 10% -10%, #1a2e24 0%, transparent 55%),
    radial-gradient(ellipse 90% 70% at 100% 0%, #252018 0%, transparent 50%),
    var(--bg);
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 1000;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* App shell -------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  min-height: 100dvh;
}

/* Header ----------------------------------------------------------------- */

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}

.header__brand {
  min-width: 140px;
}

.header__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.header__subtitle {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header__search {
  position: relative;
  flex: 1 1 220px;
  max-width: 420px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 42px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.search__input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  min-width: 0;
}

.search__clear {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text-muted);
}

.search__clear:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.search__results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
}

.search__results[hidden] {
  display: none;
}

.search__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  border-radius: 8px;
}

.search__item:hover,
.search__item[aria-selected="true"] {
  background: var(--accent-soft);
}

.search__item-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.search__item-cat {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  position: relative;
}

.map-mode {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  gap: 2px;
}

.map-mode__btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.map-mode__btn.is-active,
.map-mode__btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

[data-theme="dark"] .map-mode__btn.is-active,
[data-theme="dark"] .map-mode__btn[aria-pressed="true"] {
  color: #0a150f;
}

.gps-map {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #d5ddd8;
}

.gps-map[hidden] {
  display: none !important;
}

.main.is-gps-mode .map-viewport {
  visibility: hidden;
  pointer-events: none;
}

.main.is-gps-mode .gps-map {
  display: block;
}

.main.is-gps-mode #btn-edit {
  opacity: 0.45;
  pointer-events: none;
}

.leaflet-marker-campus {
  display: flex;
  align-items: center;
  justify-content: center;
}

.leaflet-marker-campus__dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  background: var(--marker-color, #1f6b4a);
  transition: transform 0.15s ease;
}

.leaflet-marker-campus.is-selected .leaflet-marker-campus__dot,
.leaflet-marker-campus:hover .leaflet-marker-campus__dot {
  transform: scale(1.35);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--marker-color, #1f6b4a) 35%, transparent),
    0 2px 8px rgba(0, 0, 0, 0.4);
}

.leaflet-container a.leaflet-popup-close-button {
  display: none;
}

.btn--icon {
  width: 38px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.more-menu[hidden] {
  display: none;
}

.more-menu__item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.more-menu__item:hover,
.more-menu__item[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.more-menu__item--accent {
  color: var(--accent);
}

.map-hint {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  max-width: calc(100% - 140px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  z-index: 28;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.map-hint.is-hidden {
  opacity: 0;
}

.filter__select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  min-width: 150px;
}

/* Buttons ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn--ghost:hover,
.btn--ghost[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

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

[data-theme="dark"] .btn--accent {
  color: #0a150f;
}

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

.btn--block {
  width: 100%;
  margin-top: 12px;
}

/* Main / map ------------------------------------------------------------- */

.main {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.map-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  background: #c5d0c4;
  touch-action: none;
  user-select: none;
}

[data-theme="dark"] .map-viewport {
  background: #0e1411;
}

.map-viewport.is-panning {
  cursor: grabbing;
}

.map-viewport.is-edit {
  cursor: default;
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: color-mix(in srgb, var(--bg) 88%, #c5d0c4);
  pointer-events: none;
  transition: opacity 0.35s var(--ease), visibility 0.35s;
}

.map-loading.is-done {
  opacity: 0;
  visibility: hidden;
}

.map-loading__spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: map-spin 0.8s linear infinite;
}

.map-loading__text {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

@keyframes map-spin {
  to {
    transform: rotate(360deg);
  }
}

.info-backdrop {
  position: absolute;
  inset: 0;
  z-index: 44;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(12, 18, 14, 0.35);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.28s var(--ease);
  display: none;
}

.info-backdrop[hidden] {
  display: none;
}

.info-backdrop.is-open {
  opacity: 1;
}

.info-panel__handle {
  display: none;
}

.map-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center center;
  will-change: transform;
  backface-visibility: hidden;
}

.map-image {
  width: auto;
  height: auto;
  max-width: none;
  display: block;
  pointer-events: none;
  /* Natural size set via JS after load for consistent overlay sizing */
  user-select: none;
  -webkit-user-drag: none;
}

.map-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Isolate marker paints from map image */
  contain: layout style;
}

/* While panning / zooming / dragging — kill expensive effects */
.map-viewport.is-interacting .marker,
.map-viewport.is-interacting .marker__tooltip {
  transition: none !important;
  animation: none !important;
}

.map-viewport.is-interacting .marker__tooltip {
  opacity: 0 !important;
}

.map-viewport.is-interacting .minimap {
  opacity: 0.55;
}

/* Hotspots — invisible building hit areas -------------------------------- */

.marker {
  position: absolute;
  width: var(--hotspot-w, 2.8%);
  height: var(--hotspot-h, 3.2%);
  margin: 0;
  padding: 0;
  border: 1.5px solid transparent;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: background 0.12s ease, border-color 0.12s ease;
  animation: none;
  z-index: 2;
  touch-action: none;
  contain: layout style;
}

/* Invisible by default; soft tint on interaction */
.marker:hover,
.marker:focus-visible {
  z-index: 5;
  background: rgba(31, 107, 74, 0.28);
  border-color: rgba(31, 107, 74, 0.75);
}

.marker.is-selected,
.marker.is-highlighted {
  z-index: 6;
  background: rgba(31, 107, 74, 0.34);
  border-color: var(--marker-color, var(--accent));
  box-shadow: 0 0 0 2px rgba(31, 107, 74, 0.35);
}

.marker.is-filtered-out {
  visibility: hidden;
  pointer-events: none;
}

.marker.is-dragging {
  z-index: 20;
  cursor: grabbing;
  background: rgba(31, 107, 74, 0.45);
  border-color: var(--accent);
  transition: none;
}

/* Edit Mode: light outlines only (cheap to paint) */
.is-edit .marker {
  background: rgba(31, 107, 74, 0.12);
  border: 1.5px dashed rgba(31, 107, 74, 0.55);
}

.is-edit .marker.is-filtered-out {
  visibility: visible;
  opacity: 0.2;
  pointer-events: none;
}

.is-edit .marker.is-edit-selected {
  background: rgba(180, 35, 24, 0.22);
  border: 2px solid #b42318;
  border-style: solid;
  z-index: 8;
}

.marker__tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 5px 10px;
  background: var(--text);
  color: var(--surface);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  box-shadow: var(--shadow-sm);
  will-change: opacity;
}

.marker__tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: var(--text);
}

.marker:hover .marker__tooltip,
.marker:focus-visible .marker__tooltip,
.marker.is-selected .marker__tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.is-edit .marker:hover .marker__tooltip,
.is-edit .marker.is-dragging .marker__tooltip {
  opacity: 0;
}

.marker__coords {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  display: none;
}

.marker.is-dragging .marker__coords,
.is-edit .marker.is-edit-selected .marker__coords {
  display: block;
}

/* Map controls ----------------------------------------------------------- */

.map-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 30;
}

.control-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  transition: background 0.15s;
}

.control-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.control-btn--wide {
  width: auto;
  padding: 0 12px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

/* Mini-map --------------------------------------------------------------- */

.minimap {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 140px;
  height: 90px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow);
  z-index: 30;
  background: #9aab9a;
  opacity: 0.95;
}

.minimap__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.minimap__viewport {
  position: absolute;
  border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  pointer-events: none;
  box-sizing: border-box;
}

/* Coordinate / edit panel ------------------------------------------------ */

.coord-panel {
  position: absolute;
  left: 16px;
  top: 16px;
  width: min(260px, calc(100% - 32px));
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 35;
}

.coord-panel[hidden] {
  display: none;
}

.coord-panel__title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.coord-panel__hint {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.coord-panel__active {
  padding: 10px;
  background: var(--bg-elevated);
  border-radius: 8px;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.coord-panel__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.coord-panel__actions .btn--block {
  margin-top: 0;
}

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

.btn--danger:hover:not(:disabled) {
  background: #912018;
}

.btn--danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Info panel ------------------------------------------------------------- */

.info-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-w);
  height: auto;
  max-height: none;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 45;
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform 0.35s var(--ease);
  overflow: hidden;
}

.info-panel.is-open {
  transform: translateX(0);
}

.info-panel[hidden] {
  display: flex;
  visibility: hidden;
  pointer-events: none;
}

.info-panel.is-open[hidden] {
  visibility: visible;
  pointer-events: auto;
}

.info-panel__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  font-size: 1.4rem;
  z-index: 2;
  line-height: 1;
}

.info-panel__close:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.info-panel__media {
  height: 180px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  overflow: hidden;
}

.info-panel__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.info-panel__body {
  padding: 18px 20px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Mobile / compact: bottom sheet card (toggled by .layout-sheet on #app) */
.layout-sheet .info-backdrop:not([hidden]) {
  display: block;
}

.layout-sheet .info-panel {
  top: auto;
  right: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  max-width: none;
  height: auto;
  max-height: min(70dvh, 560px);
  border-left: none;
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.22);
  transform: translate3d(0, 110%, 0);
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}

.layout-sheet .info-panel.is-open {
  transform: translate3d(0, 0, 0);
}

.layout-sheet .info-panel.is-dragging {
  transition: none;
}

.layout-sheet .info-panel__handle {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 0 6px;
  flex-shrink: 0;
  touch-action: none;
  cursor: grab;
}

.layout-sheet .info-panel__handle span {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 55%, transparent);
}

.layout-sheet .info-panel__media {
  height: 100px;
  margin: 0 14px;
  border-radius: 12px;
  flex-shrink: 0;
}

.layout-sheet .info-panel__close {
  width: 44px;
  height: 44px;
  top: 4px;
  right: 8px;
}

.layout-sheet .info-panel__body {
  padding: 10px 16px 18px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.layout-sheet .info-panel__title {
  font-size: 1.22rem;
}

.layout-sheet .info-panel__desc {
  font-size: 0.88rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.layout-sheet .info-panel__actions .btn {
  min-height: 44px;
  width: 100%;
}

.layout-sheet .main.has-sheet .map-controls {
  bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) + min(40dvh, 260px)));
}

.layout-sheet .main.has-sheet .map-hint {
  display: none;
}

.info-panel__category {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.info-panel__title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  line-height: 1.2;
}

.info-panel__desc {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.info-panel__meta {
  margin: 0;
}

.info-panel__meta > div {
  margin-bottom: 12px;
}

.info-panel__meta dt {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.info-panel__meta dd {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.info-panel__facilities {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.info-panel__facilities > .info-panel__floor {
  flex: 1 1 100%;
  padding: 0;
  background: transparent;
  color: inherit;
  border-radius: 0;
  font-size: inherit;
  font-weight: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.info-panel__floor-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.info-panel__facilities li {
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.info-panel__floor .info-panel__facilities {
  margin: 0;
}

.info-panel__actions {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Footer ----------------------------------------------------------------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  z-index: 40;
  min-height: var(--footer-h);
}

.footer__section {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.footer__section--right {
  justify-content: flex-end;
}

.footer__label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-width: 0;
}

.breadcrumb__item {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.breadcrumb__item:hover {
  text-decoration: underline;
}

.breadcrumb__sep {
  color: var(--text-muted);
  margin: 0 2px;
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recent-list button {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 0.72rem;
  font-weight: 500;
}

.recent-list button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Modal ------------------------------------------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 16, 12, 0.55);
}

.modal__dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.modal__dialog h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
}

.modal__dialog p {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.modal__textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  resize: vertical;
}

.modal__actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}

/* Responsive ------------------------------------------------------------- */

@media (max-width: 900px) {
  .header__subtitle {
    display: none;
  }

  .header__title {
    font-size: 1.15rem;
  }

  .minimap {
    width: 110px;
    height: 72px;
  }
}

@media (max-width: 720px) {
  :root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
  }

  .map-mode__btn {
    height: 36px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  html,
  body {
    height: 100%;
    height: 100dvh;
    overscroll-behavior: none;
  }

  .app {
    height: 100dvh;
    grid-template-rows: auto 1fr auto;
    padding-top: var(--safe-top);
  }

  .header {
    padding: 8px 12px;
    padding-left: max(12px, var(--safe-left));
    padding-right: max(12px, var(--safe-right));
    gap: 8px;
  }

  .header__brand {
    min-width: 0;
    flex: 1;
  }

  .header__title {
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header__search {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }

  .search {
    height: 44px;
  }

  .search__input {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .header__actions {
    margin-left: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

  .map-mode {
    order: -1;
    flex: 1 1 auto;
    min-width: 0;
  }

  .map-mode__btn {
    flex: 1;
    text-align: center;
    padding: 0 8px;
  }

  .filter__select {
    min-width: 0;
    max-width: 42vw;
    height: 44px;
    font-size: 0.85rem;
  }

  .btn--icon {
    width: 44px;
    height: 44px;
  }

  /* Give the map almost all vertical space */
  .footer {
    display: none;
  }

  .minimap {
    display: none;
  }

  .map-hint {
    display: block;
    bottom: max(16px, calc(var(--safe-bottom) + 72px));
  }

  .map-controls {
    right: max(10px, var(--safe-right));
    bottom: max(10px, calc(var(--safe-bottom) + 10px));
    gap: 8px;
  }

  .control-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    font-size: 1.5rem;
  }

  .control-btn--wide {
    width: auto;
    min-width: 48px;
    padding: 0 14px;
    font-size: 0.8rem;
  }

  /* Larger tap targets for buildings */
  .marker {
    min-width: 36px;
    min-height: 36px;
  }

  .is-edit .marker {
    min-width: 40px;
    min-height: 40px;
  }

  .coord-panel {
    left: max(10px, var(--safe-left));
    top: 10px;
    width: min(260px, calc(100% - 20px));
    max-height: 50dvh;
    overflow: auto;
  }

  .search__results {
    max-height: 50dvh;
  }

  .modal {
    padding: 12px;
    padding-bottom: max(12px, var(--safe-bottom));
    align-items: end;
  }

  .modal__dialog {
    width: 100%;
    max-height: 85dvh;
    border-radius: 16px 16px 12px 12px;
  }

  .modal__actions {
    flex-wrap: wrap;
  }

  .modal__actions .btn {
    flex: 1;
    min-height: 44px;
  }
}

@media (max-width: 380px) {
  .header__title {
    font-size: 0.95rem;
  }

  .filter__select {
    max-width: 38vw;
  }

  .map-hint {
    font-size: 0.65rem;
    padding: 6px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .marker,
  .info-panel,
  .info-backdrop,
  .btn,
  .control-btn,
  .map-hint,
  .map-loading,
  .map-loading__spinner {
    animation: none !important;
    transition: none !important;
  }
}
