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

:root {
  /* Unified UI button/toggle colors */
  --ui-btn-fg-inactive: #999;
  --ui-btn-fg-hover: #555;
  --ui-btn-fg-active: #000;
  --ui-btn-border-inactive: #ddd;
  --ui-btn-border-hover: #999;
  --ui-btn-border-active: #000;
  --ui-btn-bg-active: #f5f5f5;
  --ui-btn-underline-inactive: #ddd;
  /* 70% black utility (requested for secondary actions) */
  --ui-fg-70: rgba(0, 0, 0, 0.7);
}

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: #fff;
  color: #000;
  overflow: hidden;
}

#map {
  position: absolute; top: 0; left: 0;
  width: 66.67vw; height: 100vh;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
#map.detail-open {
  width: 33.33vw;
}

/* ── Header ── */
#header {
  position: absolute;
  top: 24px; left: 24px;
  z-index: 10;
}
#header-toggle {
  display: none;
}
#header h1 {
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  pointer-events: none;
}
#header p {
  font-size: 12px; color: #888;
  letter-spacing: 0.08em;
  pointer-events: none; margin-top: 4px;
}

/* ── Lang switch ── */
#lang-switch { display: flex; align-items: center; gap: 5px; margin-top: 6px; }
.lang-btn {
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 10px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ui-btn-fg-inactive); padding: 0; transition: color 0.15s;
}
.lang-btn.active { color: var(--ui-btn-fg-active); }
.lang-btn:hover:not(.active) { color: var(--ui-btn-fg-hover); }
.header-about-btn { font-weight: 400; color: var(--ui-btn-fg-inactive); }
.header-about-btn:hover { color: var(--ui-btn-fg-hover); }
.lang-sep { font-size: 10px; color: #000; }
#header-source-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
#header-source {
  font-size: 10px; color: #000; letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none; transition: color 0.15s;
}
#header-source:hover { color: #555; }

/* ── List panel (always visible, right edge) ── */
#list-panel {
  position: absolute; top: 0; right: 0;
  width: 33.33vw; height: 100vh;
  background: #fff; border-left: 1px solid #000;
  z-index: 15; display: flex; flex-direction: column;
}
#list-header {
  padding: 0 16px;
  flex-shrink: 0;
  border-bottom: 1px solid #eee;
}

/* Desktop: no divider between SORT BY row and list */
@media (min-width: 768px) {
  #list-header {
    border-bottom: none;
  }
}

/* When bookmarks actions live inside the header, keep spacing consistent */
#list-header .bookmarks-action-row {
  margin: 0 -16px 0;
  width: calc(100% + 32px);
  /* Divider is now a dedicated element below #list-filters */
  border-top: none;
}
#list-search {
  width: 100%; border: 1px solid #ccc;
  font-family: inherit; font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 8px 10px; outline: none;
  background: transparent; color: #000;
}
#list-search-wrap {
  position: relative;
  margin-bottom: 8px;
}
#list-search-clear {
  position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: #bbb; padding: 0 2px;
  line-height: 1; display: none;
  font-family: inherit;
}
#list-search-clear:hover { color: #000; }
#list-search::placeholder { color: #bbb; }
#list-filters {
  display: flex; align-items: center; gap: 2px; padding: 8px 0; flex-wrap: wrap;
}

/* Dedicated divider under the ALL/BOOKMARKS/VISITED buttons (desktop list panel) */
.list-header-divider {
  margin: 4px -16px 0;
  width: calc(100% + 32px);
  border-top: 1px solid #eee;
  height: 0;
}
.list-sort-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin-left: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.list-sort-label {
  font-size: 8px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: #999;
  line-height: 1;
  white-space: nowrap;
  word-break: keep-all;
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0;
  flex: 0 0 auto;
}
.list-filter-btn {
  background: none; border: 1px solid var(--ui-btn-border-inactive); cursor: pointer;
  font-family: inherit; font-size: 9px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ui-btn-fg-inactive); padding: 4px 10px; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.list-filter-btn svg { vertical-align: middle; }
.list-filter-btn.active { color: var(--ui-btn-fg-active); border-color: var(--ui-btn-border-active); }
.list-filter-btn:hover:not(.active) { color: var(--ui-btn-fg-hover); border-color: var(--ui-btn-border-hover); }
.list-sort-dropdown { position: relative; }
.list-sort-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  background: none;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-btn-fg-inactive);
  padding: 0 2px;
  cursor: pointer;
  transition: color 0.15s;
  line-height: 1;
  /* Keep "SORT BY: Alphabet" strictly on one row */
  white-space: nowrap;
  flex-wrap: nowrap;
  min-width: fit-content;
}
.list-sort-trigger:hover { color: var(--ui-btn-fg-hover); }
.list-sort-trigger:focus,
.list-sort-trigger:focus-visible { outline: none; box-shadow: none; }
.list-sort-option:focus,
.list-sort-option:focus-visible { outline: none; }
#list-sort-value {
  display: inline-flex;
  align-items: center;
  height: 20px;
  flex: 0 0 auto;
  white-space: nowrap;
  word-break: keep-all;
}
.list-sort-arrow {
  flex-shrink: 0;
  transition: transform 0.2s;
  position: relative;
  top: -0.5px;
}
.list-sort-dropdown.open .list-sort-arrow { transform: rotate(180deg); }
.list-sort-menu {
  position: absolute; top: 100%; left: 0; right: auto; margin-top: 2px;
  background: #fff; border: 1px solid #999; min-width: 100%;
  box-shadow: none; display: none; z-index: 20;
}
.list-sort-dropdown.open .list-sort-menu { display: block; }
.list-sort-option {
  font-family: inherit; font-size: 8px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ui-btn-fg-inactive); padding: 6px 10px; cursor: pointer;
  border-bottom: 1px solid #eee; transition: color 0.15s, background 0.15s;
}
.list-sort-option:last-child { border-bottom: none; }
.list-sort-option:hover { color: var(--ui-btn-fg-active); background: #fafafa; }
.list-sort-option.active { color: var(--ui-btn-fg-active); background: #fff; }
.list-export-dropdown { position: relative; }
.list-export-trigger, .route-export-trigger {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; outline: none; -webkit-tap-highlight-color: transparent;
  font-family: inherit; font-size: 8px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ui-btn-fg-inactive); padding: 4px 8px; cursor: pointer;
  transition: color 0.15s;
  line-height: 1;
}
#list-header .list-export-trigger {
  /* Match sort trigger sizing so Sort↔Share gap reads evenly */
  padding: 0 2px;
  min-height: 20px;
}
#route-actions-bar .route-export-trigger {
  font-size: 9px; font-weight: 700;
}
.list-export-trigger:hover, .route-export-trigger:hover { color: var(--ui-btn-fg-hover); }
.list-export-arrow, .route-export-arrow { flex-shrink: 0; transition: transform 0.2s; }
.list-export-dropdown.open .list-export-arrow,
.route-export-dropdown.open .route-export-arrow { transform: rotate(180deg); }
.list-export-menu, .route-export-menu {
  position: absolute; bottom: 100%; right: 0; margin-bottom: 2px;
  background: #fff; border: 1px solid #ccc; min-width: 140px;
  box-shadow: none; display: none; z-index: 20;
}
.list-export-menu {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: 2px;
}
.list-export-dropdown.open .list-export-menu,
.route-export-dropdown.open .route-export-menu { display: block; }
.list-export-option, .route-export-option {
  display: block; width: 100%; white-space: nowrap;
  font-family: inherit; font-size: 8px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ui-btn-fg-inactive); padding: 6px 10px; cursor: pointer; background: none; border: none;
  border-bottom: 1px solid #eee; transition: color 0.15s, background 0.15s;
  text-align: left;
}
.list-export-option:last-child, .route-export-option:last-child { border-bottom: none; }
.list-export-option:hover:not(:disabled), .route-export-option:hover:not(:disabled) { color: #000; background: #fafafa; }
.list-export-option:disabled, .route-export-option:disabled { color: #ccc; cursor: default; }
.route-export-dropdown { position: relative; flex-shrink: 0; }
.map-geolocate-btn {
  width: 20px !important; height: 20px !important;
  display: flex !important; align-items: center !important; justify-content: center !important;
  padding: 0; background: #fff; border: none; cursor: pointer;
  color: rgba(0,0,0,0.75); transition: color 0.15s, background 0.15s;
}
.map-geolocate-btn:hover { color: #000; background: #fff; }
.map-geolocate-btn.active { color: #000; background: #fff; }
.map-geolocate-btn svg { display: block; flex-shrink: 0; }
/* Compass — darker default arrow */
.mapboxgl-ctrl-compass { opacity: 1 !important; }
#list-panel.list-collapsed .list-filter-btn.active { opacity: 0.5; }
#list-panel.list-collapsed .list-sort-wrap { display: none; }
#list-panel.list-collapsed #list-sort-row { display: none; }
#list-panel.list-collapsed #route-section { margin-top: 0; }
#list-body {
  overflow-y: auto; flex: 1 1 0; min-height: 0;
}
.route-from-bookmarks-btn {
  display: block; width: 100%; padding: 10px 16px;
  background: none; border: none; border-bottom: 1px solid #eee;
  cursor: pointer; font-family: inherit;
  font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ui-fg-70); text-align: left;
  transition: background 0.15s, color 0.15s;
}
.route-from-bookmarks-btn:hover { background: #f5f5f5; color: #000; }

/* Desktop: don't "preview activate" route creation / add-to-route on hover */
@media (min-width: 768px) {
  .route-from-bookmarks-btn:hover {
    background: none;
    color: var(--ui-fg-70);
  }
  #panel-actions .panel-action-btn[data-action="route"].aalto-btn-outline:not(.active):hover {
    color: var(--ui-btn-fg-inactive);
    border-color: var(--ui-btn-border-inactive);
    background-color: transparent;
  }
}

/* Desktop: when "add in view" lives inside #list-header, undo header padding */
#list-header #route-from-visible.route-from-bookmarks-btn {
  margin: 0 -16px;
  width: calc(100% + 32px);
  /* Divider is now a dedicated element below #list-filters */
  border-top: none;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* Desktop: no divider between "ADD IN VIEW" and SORT BY */
@media (min-width: 768px) {
  #list-header #route-from-visible.route-from-bookmarks-btn {
    border-bottom: none;
  }
}

/* Spacing below the filter buttons is handled by .list-header-divider */

/* Desktop: Sort row lives below action rows and above list */
#list-sort-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 6px 16px;
  margin: 0 -16px;
  width: calc(100% + 32px);
  border-top: 1px solid #eee;
  border-bottom: none;
}
#list-sort-row .list-sort-wrap {
  justify-content: flex-start;
}

/* Desktop: remove divider + tighten gap under SORT BY */
@media (min-width: 768px) {
  #list-sort-row {
    border-top: none;
    padding-top: 2px;
    padding-bottom: 2px;
  }
  /* First sticky group header shouldn't add extra whitespace */
  #list-body .list-group-header:first-child {
    padding-top: 6px;
  }
}

/* Desktop: ALL tab only — make "add in view" row slightly tighter */
#list-panel[data-active-filter="all"] #list-header #route-from-visible.route-from-bookmarks-btn {
  min-height: 38px;
  padding-top: 8px;
  padding-bottom: 8px;
}

/* ── Bookmarks action row (desktop): NEW ROUTE + SHARE on one line ── */
.bookmarks-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  /* Avoid stacked dividers with sort row below */
  border-bottom: none;
  flex-shrink: 0;
  min-height: 40px;
}
.bookmarks-action-row #route-from-bookmarks.route-from-bookmarks-btn {
  width: auto;
  padding: 0;
  border-bottom: none;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bookmarks-action-row #list-export-dropdown { flex: 0 0 auto; }
/* Share: same font size as NEW ROUTE, one weight step lower */
.bookmarks-action-row .list-export-trigger {
  font-size: 9px;
  font-weight: 600;
  padding: 0;
  min-height: 20px;
}
.list-group-header {
  position: sticky; top: 0; background: #fff;
  font-size: 9px; font-weight: 400; letter-spacing: 0.16em;
  text-transform: uppercase; color: #aaa;
  padding: 12px 16px 4px; border-bottom: 1px solid #f0f0f0;
  z-index: 1; cursor: pointer; display: flex;
  align-items: center; justify-content: space-between;
  user-select: none;
}
.list-group-header:hover { color: #666; }
.list-group-arrow {
  display: inline-flex; align-items: center;
  transition: transform 0.2s;
}
.list-group-header.collapsed .list-group-arrow {
  transform: rotate(-90deg);
}
.list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px; cursor: pointer;
  border-bottom: 1px solid #f0f0f0; transition: background 0.1s;
  scroll-margin-top: 32px;
}
.list-item:hover { background: #fafafa; }
.list-item.active { background: #f0f0f0; }
.list-item-name {
  flex: 1; font-size: 13px; letter-spacing: 0.03em;
  color: rgba(0,0,0,0.85);
  line-height: 1.4; min-width: 0;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  max-height: 2.8em;
}
.list-item-meta {
  font-size: 11px; color: #999; font-weight: 400;
}
.list-item-num {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.75); color: #fff;
  font-size: 9px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-right: 8px; vertical-align: middle;
}
.list-actions {
  display: flex; gap: 2px; flex-shrink: 0;
}
.list-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: #ddd;
  transition: color 0.15s;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.list-action-btn:hover { color: #888; }
.list-action-btn.active { color: #000; }

/* ── Detail panel (slides in beside list panel) ── */
#panel {
  position: absolute; top: 0; right: 33.33vw;
  width: 33.33vw; height: 100vh;
  background: #fff; border-left: 1px solid #000;
  z-index: 14; display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
#panel.open { opacity: 1; pointer-events: auto; }

#panel-inner {
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}

#panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  flex-shrink: 0;
}
#panel-close {
  background: none; border: none; cursor: pointer;
  font-size: 14px; font-family: inherit; color: #000;
  transition: opacity 0.15s; padding: 0; line-height: 1;
}
#panel-close:hover { opacity: 0.4; }

/* Carousel */
#panel-carousel {
  width: 100%; height: max(280px, 22vw); flex-shrink: 0;
  overflow: hidden; background: #e8e8e8;
  border-bottom: 1px solid #000; position: relative;
}
#carousel-img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; transition: opacity 0.2s;
}
#carousel-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  color: #999; background: #e8e8e8;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  pointer-events: none;
}
#carousel-placeholder[hidden] { display: none; }
#panel-carousel:has(#carousel-placeholder:not([hidden])) { cursor: default; }
#carousel-img.loading { opacity: 0; }
#carousel-caption {
  position: absolute; bottom: 0; right: 0;
  padding: 0;
  background: transparent;
  font-size: 10px; color: #555; letter-spacing: 0.06em; line-height: 1.4;
  display: flex; align-items: flex-start; gap: 0;
}
#carousel-caption-text { flex: 1; min-width: 0; padding: 4px 10px; }
#carousel-nav {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
  padding: 4px 6px; background: transparent;
}
/* Carousel close (mobile only; hidden on desktop) */
.bs-close-carousel { display: none; }

#carousel-prev, #carousel-next {
  background: none; border: none;
  width: 22px; height: 22px; cursor: pointer;
  font-size: 14px; font-family: inherit; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  color: #000; transition: color 0.15s;
}
#carousel-prev svg, #carousel-next svg { display: block; }
#carousel-prev:hover, #carousel-next:hover { color: #000; }

#panel-carousel { cursor: zoom-in; }

/* Scrollable body — min-height: 0 so flex item can shrink and overflow-y creates scroll */
#panel-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 0;
}

#panel-name {
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  line-height: 1.6; margin-bottom: 4px;
}
#panel-actions {
  display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap;
}
.aalto-btn-outline {
  background: none;
  border: 1px solid var(--ui-btn-border-inactive);
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.aalto-btn-outline svg { display: block; flex-shrink: 0; }
.aalto-btn-outline:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}
.aalto-btn-outline:hover {
  border-color: var(--ui-btn-border-active);
  color: var(--ui-btn-fg-active);
}

/* Desktop: route action buttons should be unboxed (no outlines) */
@media (min-width: 768px) {
  /* Desktop: keep list toolbar height stable across tabs */
  #list-filters { align-items: center; }
  .list-sort-wrap { align-items: center; }

  /* Desktop: keep "SORT BY" aligned to the right edge */
  .list-toolbar-right {
    justify-content: flex-end;
    text-align: right;
  }

  #route-actions-bar .aalto-btn-outline {
    border-color: transparent;
  }
  #route-actions-bar .aalto-btn-outline:hover {
    border-color: transparent;
  }

  /* Desktop: bookmarks tab SHARE should be unboxed too */
  #list-header .list-export-trigger.aalto-btn-outline {
    border-color: transparent;
  }
  #list-header .list-export-trigger.aalto-btn-outline:hover {
    border-color: transparent;
  }
  .bookmarks-action-row .list-export-trigger.aalto-btn-outline {
    border-color: transparent;
  }
  .bookmarks-action-row .list-export-trigger.aalto-btn-outline:hover {
    border-color: transparent;
  }

  /* Desktop: info panel active buttons shouldn't be filled */
  #panel-actions .panel-action-btn.active {
    background-color: transparent;
    /* Toggled-on state should read as dark on desktop */
    color: var(--ui-btn-fg-active);
    border-color: var(--ui-btn-border-active);
  }
  #panel-actions .panel-action-btn.active:hover {
    background-color: transparent;
    color: var(--ui-btn-fg-active);
    border-color: var(--ui-btn-border-active);
  }

  /* Desktop: don't dim buttons on mouse-down */
  #panel-actions .panel-action-btn:active {
    opacity: 1;
  }

  /* Desktop: info panel action buttons match list filter outline weight */
  #panel-actions .panel-action-btn.aalto-btn-outline:not(.active) {
    border-width: 1px;
    color: var(--ui-btn-fg-inactive);
    border-color: var(--ui-btn-border-inactive);
  }
  #panel-actions .panel-action-btn.aalto-btn-outline:not(.active):hover {
    color: var(--ui-btn-fg-hover);
    border-color: var(--ui-btn-border-hover);
  }

  /* Desktop: slightly softer black for route actions */
  #route-from-bookmarks,
  #route-from-visible,
  #route-optimize,
  #route-gmaps,
  #route-collapsed-gmaps {
    color: var(--ui-fg-70);
  }
  #route-from-bookmarks:hover,
  #route-from-visible:hover,
  #route-optimize:hover,
  #route-gmaps:hover,
  #route-collapsed-gmaps:hover {
    color: #000;
  }

  /* Desktop: make SHARE label darker */
  #route-actions-bar .route-export-trigger,
  #list-header .list-export-trigger {
    color: #666;
  }
  #route-actions-bar .route-export-trigger:hover,
  #list-header .list-export-trigger:hover {
    color: #000;
  }
}

/* Desktop (narrow list panel): keep ALL/BOOKMARKS/VISITED first.
   When the list panel gets tight, keep filter buttons on the first row. */
@media (min-width: 768px) and (max-width: 1259px) {
  #list-filters { row-gap: 8px; }
  #list-sort-row { justify-content: flex-start; }
}
.aalto-btn {
  background: #111;
  border: 1px solid #111;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 10px;
  cursor: pointer;
  color: #fff;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.aalto-btn svg { display: block; flex-shrink: 0; }
.aalto-btn:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}
.aalto-btn:hover {
  background-color: #000;
  border-color: #000;
  color: #fff;
}
.panel-action-btn {
  color: var(--ui-btn-fg-inactive);
  line-height: 1;
}
.panel-action-sym { font-size: 14px; line-height: 0; position: relative; top: -1px; }
.panel-action-btn:hover { color: var(--ui-btn-fg-active); }
.panel-action-btn.active {
  color: var(--ui-btn-fg-active);
  border-color: var(--ui-btn-border-active);
  background-color: transparent;
}
#panel-address-row {
  display: flex; align-items: baseline;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
#panel-address {
  font-size: 12px; color: #888;
  letter-spacing: 0.05em; line-height: 1.7; margin: 0; flex: 1; min-width: 0;
}
.panel-gmaps-link {
  flex-shrink: 0;
  font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ui-fg-70); text-decoration: none;
  transition: opacity 0.15s;
}
.panel-gmaps-link:hover { opacity: 0.5; }
#panel-description {
  font-size: 13.5px; color: #333;
  line-height: 1.75; margin-bottom: 10px;
  display: none;
}
#panel-description p { margin: 0 0 1em; }
#panel-description p:last-child { margin-bottom: 0; }
#panel-description.visible { display: block; }
.desc-rest { display: none; }
.desc-rest.expanded { display: block; }

.desc-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 11px; font-weight: 400; letter-spacing: 0;
  text-transform: none; color: var(--ui-btn-fg-inactive); padding: 6px 0 0;
  transition: opacity 0.15s; font-family: inherit;
}
.desc-toggle:hover { opacity: 0.5; }

/* Footer: links & contacts */
#panel-footer {
  padding: 0 0 10px;
  display: flex; flex-direction: column; gap: 6px;
}

.panel-footer-row {
  display: flex; align-items: flex-end; gap: 18px;
}
.panel-footer-label {
  font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: #bbb;
  width: 60px; flex-shrink: 0;
  line-height: 1.4;
}
.panel-footer-value {
  font-size: 12px; color: #000;
  text-decoration: none; letter-spacing: 0.03em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
a.panel-footer-value:hover { opacity: 0.5; }

.attribution-row {
  font-size: 11px; color: #999; letter-spacing: 0.03em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attribution-row a {
  color: #999; text-decoration: none;
}
.attribution-row a:hover { opacity: 0.5; }

#panel-social {
  display: flex; gap: 12px; padding-bottom: 4px;
}
#panel-social:empty { display: none; }
#panel-contact:empty { display: none; }
.social-link {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: #000; text-decoration: none;
  border-bottom: 1px solid #000; padding-bottom: 1px;
  transition: opacity 0.15s;
}
.social-link:hover { opacity: 0.4; }

/* Lightbox */
#lightbox {
  display: none; position: fixed; inset: 0;
  background: rgba(255,255,255,0.92); z-index: 150;
  align-items: center; justify-content: center;
  flex-direction: column;
}
#lightbox.open { display: flex; }
#lightbox-img { max-width: 90vw; max-height: 80vh; object-fit: contain; }
#lightbox-caption {
  color: #000; font-size: 13px; letter-spacing: 0.06em;
  margin-top: 12px; text-align: center; padding: 0 40px;
}
#lightbox-close {
  position: fixed; top: 16px; right: 16px;
  background: none; border: none; color: #000;
  font-size: 18px; cursor: pointer;
}
#lightbox-prev, #lightbox-next {
  position: fixed; bottom: 16px;
  background: none; border: none; color: #000;
  font-size: 18px; cursor: pointer; padding: 8px;
}
#lightbox-prev { right: 52px; }
#lightbox-next { right: 16px; }
#lightbox-prev:hover, #lightbox-next:hover,
#lightbox-close:hover { opacity: 0.5; }

/* Desktop: arrows centered left/right of image */
@media (min-width: 768px) {
  #lightbox-prev, #lightbox-next {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    padding: 14px;
  }
  #lightbox-prev {
    left: 16px;
    right: auto;
  }
  #lightbox-next {
    right: 16px;
  }
}
#lightbox-thumbs {
  display: flex; gap: 4px; margin-top: 12px;
  overflow-x: auto; max-width: 90vw; padding: 4px 0;
}
.lb-thumb {
  width: 48px; height: 36px; flex-shrink: 0;
  object-fit: cover; cursor: pointer;
  opacity: 0.4; transition: opacity 0.15s;
  border: 1px solid transparent;
}
.lb-thumb:hover { opacity: 0.7; }
.lb-thumb.active { opacity: 1; border-color: #000; }

/* ── Route section (bottom of list panel) ── */
#route-section {
  border-top: 1px solid #000;
  background: #fff;
  flex-shrink: 0;
}
#route-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; cursor: pointer;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
}
#route-toggle {
  display: inline-flex; align-items: center;
  margin-left: auto;
  transition: transform 0.2s;
}
#route-toggle svg { width: 10px; height: 6px; }
#route-section.collapsed #route-toggle { transform: rotate(-90deg); }
#route-section.collapsed #route-section-body { display: none; }
#route-collapsed-info {
  padding: 0 16px 12px;
  display: flex; align-items: center; gap: 8px;
  font-size: 9px; font-weight: 400;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: #888;
}
#route-collapsed-info .route-action-link {
  margin-left: auto;
  font-size: 8px;
}
.route-title { color: #000; }
#route-summary-row {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; padding: 4px 0 6px;
}
#route-summary {
  color: #000; font-weight: 700; font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.route-clear-text-btn {
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 9px; font-weight: 700;
  letter-spacing: 0.12em; color: #000;
  text-transform: uppercase; transition: color 0.15s;
  margin-left: auto; padding: 0;
}
.route-clear-text-btn:hover { color: var(--ui-btn-fg-hover); }
.route-clear-cross { font-size: 12px; line-height: 1; }
#route-section-body {
  padding: 0 16px 12px;
  display: flex; flex-direction: column;
  max-height: 50vh; overflow-y: auto;
}
#route-mode-bar {
  display: flex; gap: 2px; margin-bottom: 6px; flex-wrap: wrap;
  flex-shrink: 0;
}
#route-summary-row + #route-mode-bar {
  margin-top: 6px;
}
.route-mode-btn {
  background: none; border: none;
  cursor: pointer; padding: 3px 4px 4px;
  font-family: inherit; font-size: 9px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  position: relative;
  transition: all 0.15s; color: var(--ui-btn-fg-inactive);
}
.route-mode-btn::after {
  content: ''; position: absolute;
  bottom: 0; left: 2px; right: 2px;
  height: 2px; background: var(--ui-btn-underline-inactive);
}
.route-mode-btn[data-mode="WALKING"]::after {
  background: repeating-linear-gradient(to right, var(--ui-btn-underline-inactive) 0px, var(--ui-btn-underline-inactive) 4px, transparent 4px, transparent 8px);
}
.route-mode-btn[data-mode="BICYCLING"]::after {
  background: repeating-linear-gradient(to right, var(--ui-btn-underline-inactive) 0px, var(--ui-btn-underline-inactive) 1px, transparent 1px, transparent 4px);
}
.route-mode-btn[data-mode="TRANSIT"]::after {
  background: repeating-linear-gradient(to right, var(--ui-btn-underline-inactive) 0 8px, transparent 8px 12px, var(--ui-btn-underline-inactive) 12px 14px, transparent 14px 18px);
}
.route-mode-btn:hover { color: var(--ui-btn-fg-active); }
.route-mode-btn.active { color: var(--ui-btn-fg-active); }
.route-mode-btn.active::after { background: var(--ui-btn-fg-active); }
.route-mode-btn.active[data-mode="WALKING"]::after {
  background: repeating-linear-gradient(to right, var(--ui-btn-fg-active) 0px, var(--ui-btn-fg-active) 4px, transparent 4px, transparent 8px);
}
.route-mode-btn.active[data-mode="BICYCLING"]::after {
  background: repeating-linear-gradient(to right, var(--ui-btn-fg-active) 0px, var(--ui-btn-fg-active) 1px, transparent 1px, transparent 4px);
}
.route-mode-btn.active[data-mode="TRANSIT"]::after {
  background: repeating-linear-gradient(to right, var(--ui-btn-fg-active) 0 8px, transparent 8px 12px, var(--ui-btn-fg-active) 12px 14px, transparent 14px 18px);
}

.route-threshold-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: #999;
  margin-bottom: 8px; flex-shrink: 0;
}
.route-threshold-row.hidden { display: none; }
#route-stops-list {
  flex: 0 1 auto; overflow-y: auto; min-height: 0;
}
#walk-threshold-input {
  font-family: inherit; font-size: 9px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  border: none; border-bottom: 1px solid #ccc;
  background: none; color: #000;
  padding: 1px 2px; outline: none;
  width: 36px; text-align: center;
}
#walk-threshold-input:hover, #walk-threshold-input:focus { border-bottom-color: #000; }
#walk-threshold-input::placeholder { color: #bbb; }
.threshold-unit { color: #999; }

.route-stop-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 0; font-size: 13px;
  cursor: pointer; transition: background 0.1s;
}
.route-stop-row:hover { background: #fafafa; }
.route-stop-row.active { background: #f0f0f0; }
.route-stop-handle {
  color: #ccc; font-size: 11px; cursor: grab; flex-shrink: 0;
  user-select: none;
}
.route-stop-num {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.75); color: #fff;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.route-stop-row .list-item-num {
  background: #fff;
  color: rgba(0,0,0,0.85);
  border: 1.5px solid rgba(0,0,0,0.85);
  font-size: 8px;
  font-weight: 500;
}
.route-stop-name {
  flex: 1; min-width: 0;
  color: rgba(0,0,0,0.85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 0.03em; line-height: 1.55;
}
.route-stop-row .list-item-name {
  font-weight: 400; font-style: normal;
  text-transform: none; letter-spacing: 0.03em; font-size: 13px;
}
.route-stop-remove {
  background: none; border: none; cursor: pointer;
  color: #ccc; font-size: 14px; flex-shrink: 0;
  transition: color 0.15s;
}
.route-stop-remove:hover { color: #000; }
.route-stop-row.touch-drag-clone {
  background: #fff; border: 1px solid #000;
}

.route-segment-info {
  padding: 2px 0; margin-bottom: 2px;
  font-size: 10px; color: #999;
  letter-spacing: 0.06em;
  display: flex; align-items: center; gap: 4px;
}
.seg-arrow {
  cursor: pointer; color: #ccc;
  padding: 2px; transition: color 0.15s; user-select: none;
  display: inline-flex; align-items: center;
}
.seg-arrow:hover { color: #000; }
.seg-mode-wrap {
  display: inline-flex; align-items: center; gap: 1px;
}
.seg-mode-label {
  font-weight: 700; font-size: 10px;
  letter-spacing: 0.08em; color: #666;
  position: relative; padding-bottom: 1px;
  cursor: pointer;
}
.seg-mode-label::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1.5px;
}
.seg-mode-label[data-mode="DRIVING"]::after { background: #666; }
.seg-mode-label[data-mode="WALKING"]::after {
  background: repeating-linear-gradient(to right, #666 0 3px, transparent 3px 6px);
}
.seg-mode-label[data-mode="BICYCLING"]::after {
  background: repeating-linear-gradient(to right, #666 0 1px, transparent 1px 3px);
}
.seg-mode-label[data-mode="TRANSIT"]::after {
  background: repeating-linear-gradient(to right, #666 0 6px, transparent 6px 9px, #666 9px 11px, transparent 11px 14px);
}
.seg-way-arrow {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 10px;
  margin-right: 4px;
  color: #666;
  opacity: 0.9;
  user-select: none;
}
.seg-way-arrow::before,
.seg-way-arrow::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
}
.seg-way-arrow::before {
  left: 0;
  border-right: 4px solid currentColor;
  transform: translateY(-50%);
}
.seg-way-arrow::after {
  right: 0;
  border-left: 4px solid currentColor;
  transform: translateY(-50%);
}
.seg-way-arrow::marker,
.seg-way-arrow span {
  display: none;
}
.seg-way-arrow::selection {
  background: transparent;
}
.seg-return-check {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9px; font-weight: 600; letter-spacing: 0.06em; color: #666;
  cursor: pointer; user-select: none;
}
.seg-return-check input {
  margin: 0; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  width: 12px; height: 12px;
  border: 1px solid #999; background: transparent;
}
.seg-return-check input:checked {
  background: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2' d='M2 6l3 3 5-6'/%3E%3C/svg%3E");
  background-size: contain;
}
.seg-details { color: #999; }
.route-return-row { padding-left: 8px; opacity: 0.75; }
.seg-return-icon {
  position: relative;
  display: inline-block;
  width: 12px;
  height: 10px;
  margin-right: 4px;
  color: #666;
  user-select: none;
}
.seg-return-icon::before,
.seg-return-icon::after {
  content: '';
  position: absolute;
  border-color: currentColor;
}
.seg-return-icon::before {
  left: 2px;
  right: 0;
  top: 50%;
  border-top: 1px solid currentColor;
  transform: translateY(-50%);
}
.seg-return-icon::after {
  left: 0;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  border-right: 4px solid currentColor;
  transform: translateY(-50%);
}
.seg-return-label { cursor: default; font-weight: 600; font-size: 10px; color: #666; letter-spacing: 0.08em; }

#route-actions-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
  border-top: 1px solid #e8e8e8;
  margin-top: 6px;
  flex-shrink: 0;
}

/* Keep route actions on one clean row */
#route-actions-bar .aalto-btn-outline,
#route-actions-bar .route-export-trigger {
  align-items: center;
  line-height: 1;
  min-height: 22px;
  white-space: nowrap;
}

/* Route actions: slightly tighter so they fit on one line */
#route-actions-bar .aalto-btn-outline,
#route-actions-bar .route-export-trigger {
  padding: 3px 8px;
}

/* Desktop: route actions evenly spaced + vertically aligned */
@media (min-width: 768px) {
  /* Desktop: align actions from the left (no full-width grid spreading) */
  #route-actions-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
  }

  #route-actions-bar > button,
  #route-actions-bar > .route-export-dropdown {
    width: auto;
  }

  #route-actions-bar .aalto-btn-outline,
  #route-actions-bar .route-export-trigger {
    justify-content: flex-start;
  }

  /* Tiny optical alignment for the dropdown arrow */
  #route-actions-bar .route-export-arrow {
    position: relative;
    top: -0.5px;
  }
}
.route-action-link {
  background: none; border: none; cursor: pointer;
  padding: 0;
  font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase; color: var(--ui-btn-fg-inactive);
  transition: opacity 0.15s;
}
.route-action-link:hover { opacity: 0.5; }

.route-empty-hint {
  font-size: 10px; color: #bbb; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 12px 0;
  text-align: center;
}
.route-stop-indicator {
  color: #ccc; flex-shrink: 0;
  display: inline-flex; align-items: center;
}

/* ── Destinations list header ── */
#list-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; cursor: pointer;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  flex-shrink: 0;
}
#list-section-header:hover { color: #666; }
#list-toggle {
  display: inline-flex; align-items: center;
  margin-left: auto;
  transition: transform 0.2s;
}
#list-toggle svg { width: 10px; height: 6px; }
#list-count { color: #888; font-weight: 400; font-size: 9px; letter-spacing: 0.06em; }

/* ── Minimized panel layout (both sections collapsed) ── */
#list-panel.minimized {
  height: auto;
  overflow: hidden;
  border-bottom: 1px solid #000;
}
#list-panel.list-collapsed {
  height: auto;
  border-bottom: 1px solid #000;
}

/* ── Layer zoom config panel ── */
.layer-zoom-panel {
  position: fixed;
  bottom: 60px;
  left: 12px;
  width: 220px;
  max-height: 50vh;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #000;
  z-index: 100;
  display: flex;
  flex-direction: column;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.layer-zoom-panel.collapsed .layer-zoom-body {
  display: none;
}
.layer-zoom-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-bottom: 1px solid #ccc;
  font-weight: 600;
}
#layer-zoom-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  padding: 2px 4px;
}
.layer-zoom-body {
  overflow-y: auto;
  padding: 6px 8px;
}
.layer-zoom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid #eee;
}
.layer-zoom-row:last-child { border-bottom: none; }
.layer-zoom-label {
  flex: 1;
  min-width: 0;
  font-size: 9px;
}
.layer-zoom-field {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 8px;
  color: #666;
  text-transform: none;
}
.layer-zoom-minmax {
  width: 24px;
}
.layer-zoom-field input {
  width: 40px;
  padding: 2px 4px;
  font-size: 10px;
  border: 1px solid #ccc;
  font-family: inherit;
}
.layer-zoom-zoom {
  font-size: 9px;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #000;
  background: #f0f0f0;
  border: 1px solid #ccc;
  padding: 1px 5px;
  margin-left: auto;
  margin-right: 6px;
  min-width: 52px;
  text-align: center;
  flex-shrink: 0;
}
.layer-zoom-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.25);
  cursor: pointer;
}

/* ── Toast notification ── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #000; color: #fff;
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 8px 16px; z-index: 200;
  opacity: 0; transition: opacity 0.3s;
  pointer-events: none;
}
#toast.visible { opacity: 1; }

/* ── Loading dots ── */
@keyframes dot-pulse { 0%,80%,100% { opacity: 0; } 40% { opacity: 1; } }
.loading-dots { display: inline-flex; gap: 1px; margin-left: 4px; }
.loading-dots span {
  animation: dot-pulse 1.4s infinite;
  font-size: 14px; font-weight: 700; color: #888;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ── Mapbox controls ── */
.mapboxgl-ctrl-group {
  border-radius: 0 !important; box-shadow: none !important;
  border: 1px solid rgba(0,0,0,0.3) !important; background: #fff !important;
}
.mapboxgl-ctrl-group button {
  border-radius: 0 !important;
  width: 28px !important;
  height: 28px !important;
  opacity: 0.6;
  touch-action: manipulation;
  padding: 0 !important;
}
.mapboxgl-ctrl-group button .mapboxgl-ctrl-icon { background-size: 75%; }
.mapboxgl-ctrl-group button:hover { opacity: 0.8; }
.mapboxgl-ctrl-group button + button { border-top: 1px solid rgba(0,0,0,0.15) !important; }
.mapboxgl-ctrl-attrib { font-size: 9px; background: transparent !important; }

/* ── Print map overview (screen: hidden) ── */
#print-map-overview,
#print-bookmarks-map { display: none; }

/* ── Print ── */
@media print {
  body.print-mode::before {
    content: attr(data-print-title);
    display: block;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0 16px 12px;
    border-bottom: 1px solid #000;
    margin-bottom: 12px;
  }
  body.print-mode #map, body.print-mode #header, body.print-mode .mapboxgl-ctrl,
  body.print-mode #panel, body.print-mode #toast, body.print-mode #lightbox,
  body.print-mode #layer-zoom-panel, body.print-mode .mapboxgl-control-container { display: none !important; }
  body.print-mode #list-panel { position: static; width: 100%; border-left: none !important; height: auto !important; }
  body.print-bookmarks #print-bookmarks-map {
    display: block !important; width: 100%; margin: 24px 0 0 0; outline: none; text-align: left;
  }
  body.print-bookmarks #print-bookmarks-map .print-map-label {
    font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
    display: block; margin-bottom: 8px; padding: 0 16px;
  }
  body.print-bookmarks #print-bookmarks-map img {
    display: block; width: 100%; height: auto; max-height: 55vh; object-fit: contain; object-position: left top;
    border: none; outline: none;
  }
  body.print-bookmarks #print-map-overview { display: none !important; }
  body.print-bookmarks #route-section,
  body.print-bookmarks #list-section-header, body.print-bookmarks #list-toggle,
  body.print-bookmarks #list-header, body.print-bookmarks .list-group-arrow { display: none !important; }
  body.print-bookmarks .list-group-header { border-bottom: 1px solid #000; cursor: default; }
  body.print-bookmarks .list-group-header.collapsed, body.print-bookmarks .list-group-header.collapsed + * { display: block !important; }
  body.print-bookmarks #list-body { flex: none !important; height: auto !important; min-height: 0 !important; overflow: visible !important; }
  body.print-route #print-bookmarks-map { display: none !important; }
  body.print-route #print-map-overview {
    display: block !important; width: 100%; margin: 24px 0 0 0; outline: none; text-align: left;
  }
  body.print-route #print-map-overview .print-map-label {
    font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
    display: block; margin-bottom: 8px; padding: 0 16px;
  }
  body.print-route #print-map-overview img {
    display: block; width: 100%; height: auto; max-height: 55vh; object-fit: contain; object-position: left top;
    border: none; outline: none;
  }
  body.print-route #route-section { display: block !important; }
  body.print-route #route-section.collapsed #route-section-body { display: block !important; }
  body.print-route #route-section-body, body.print-route #route-stops-list { max-height: none !important; overflow: visible !important; }
  body.print-route #list-section-header, body.print-route #list-header,
  body.print-route #list-body, body.print-route .list-group-header { display: none !important; }
  body.print-route #route-section-header,
  body.print-route #route-mode-bar,
  body.print-route #route-walk-threshold,
  body.print-route #route-actions-bar { display: none !important; }
  body.print-mode .list-item:hover,
  body.print-mode .list-item.active { background: transparent !important; }
  body.print-mode .route-stop-row:hover,
  body.print-mode .route-stop-row.active { background: transparent !important; }
  /* Hide mobile bottom sheet in print */
  body.print-mode #bottom-sheet { display: none !important; }
  /* Force list-panel visible even on mobile screens */
  body.print-mode #list-panel {
    display: block !important;
    position: static;
    width: 100%;
    height: auto !important;
    border: none;
  }
  /* Hide interactive controls in print */
  body.print-mode .route-stop-handle,
  body.print-mode .route-stop-remove,
  body.print-mode .list-actions,
  body.print-mode #route-clear,
  body.print-mode #route-optimize,
  body.print-mode #route-gmaps,
  body.print-mode #route-collapsed-gmaps,
  body.print-mode #route-export-dropdown,
  body.print-mode #list-export-dropdown,
  body.print-mode .route-mode-btn,
  body.print-mode .seg-arrow,
  body.print-mode .seg-return-check,
  body.print-mode .bs-handle,
  body.print-mode .bs-tabs,
  body.print-mode .bs-search-row,
  body.print-mode #list-search-wrap,
  body.print-mode .list-sort-wrap,
  body.print-mode #route-from-bookmarks,
  body.print-mode #route-from-visible { display: none !important; }
}

/* ═══════════════════════════════════════════════════════
   Mobile Bottom Sheet (<768px)
   ═══════════════════════════════════════════════════════ */

/* Hide bottom sheet on desktop */
#bottom-sheet { display: none; }

@media (max-width: 767px) {
  /* ── Hide desktop panels, fullscreen map ── */
  #list-panel, #panel { display: none !important; }
  #map {
    width: 100vw !important;
    height: calc(100dvh - var(--bs-height, 120px));
    position: fixed !important; top: 0; left: 0;
    transition: height 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  }
  body.bs-dragging #map {
    transition: none !important;
  }
  #map.detail-open { width: 100vw !important; }

  #header {
    top: max(12px, env(safe-area-inset-top, 0));
    left: max(12px, env(safe-area-inset-left, 0));
    z-index: 25;
    position: absolute;
    /* Make room for the toggle button on the right */
    padding-right: 28px;
  }
  #header a { cursor: pointer; }
  #header-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #000;
    -webkit-tap-highlight-color: transparent;
    width: auto;
    position: absolute;
    top: 0;
    right: 0;
  }
  /* Default (expanded): arrow points left. Hidden: points right. */
  #header-toggle svg { display: block; transform: rotate(90deg); width: 14px; height: 8px; }
  #header.header-hidden #header-content { display: none; }
  #header.header-hidden #header-source { display: none; }
  #header.header-hidden #header-source-row {
    margin-top: 0;
  }
  #header.header-hidden #header-toggle svg {
    transform: rotate(-90deg);
  }
  #header h1 { font-size: 11px; pointer-events: auto; cursor: pointer; }
  #header p { font-size: 10px; margin-top: 2px; pointer-events: auto; cursor: pointer; }

  /* ── Map controls on mobile ── */
  .mapboxgl-ctrl-bottom-left {
    left: 12px;
  }
  .mapboxgl-ctrl-group button {
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .mapboxgl-ctrl-bottom-left .mapboxgl-ctrl {
    margin: 0 0 4px 0;
  }

  /* ── Bottom sheet container ── */
  /* Height-based: grows upward from bottom. JS sets --bs-height. */
  #bottom-sheet {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 30;
    background: #fff;
    border-top: 1px solid #000;
    will-change: height;
    height: var(--bs-height, 120px);
    max-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0);
    transition: height 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
  }
  body.bs-dragging #bottom-sheet {
    transition: none !important;
  }

  /* ── Handle ── */
  .bs-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    flex-shrink: 0;
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }
  .bs-handle-bar {
    width: 32px;
    height: 2px;
    background: #ccc;
    border-radius: 1px;
  }

  /* ── Tab bar ── */
  .bs-tabs {
    display: flex;
    gap: 0;
    padding: 0 8px;
    flex-shrink: 0;
    border-bottom: 1px solid #eee;
  }
  .bs-tab {
    flex: 1 1 auto;
    min-width: 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ui-btn-fg-inactive);
    padding: 6px 2px;
    transition: color 0.2s, border-color 0.2s;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    white-space: nowrap;
  }
  .bs-tab.active {
    color: var(--ui-btn-fg-active);
    border-bottom-color: var(--ui-btn-fg-active);
  }
  .bs-tab:hover:not(.active) { color: var(--ui-btn-fg-hover); }

  /* Vertical divider before route tab */
  .bs-tab-route-divider {
    width: 1px;
    align-self: stretch;
    margin: 6px 10px;
    background: #ddd;
    flex-shrink: 0;
  }

  /* Route tab — route-specific overrides only (base layout inherited from .bs-tab) */
  .bs-tab-route.active {
    color: var(--ui-btn-fg-active);
    border-bottom-color: var(--ui-btn-fg-active);
  }

  /* ── Search row (search + sort on mobile) ── */
  .bs-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 4px 12px 0;
    margin-bottom: 6px;
    flex-shrink: 0;
  }
  .bs-search-row #list-search-wrap {
    margin: 0;
    flex: 1;
    min-width: 0;
  }
  .bs-search-row #list-search {
    font-size: 11px;
    padding: 6px 8px;
    border: 1px solid #ccc;
  }
  .bs-search-row .list-sort-wrap {
    flex-shrink: 0;
    margin-left: 0;
  }

  /* ── Sort row — subtle controls ── */
  .bs-secondary-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #999;
  }
  .list-sort-label,
  .list-sort-trigger {
    font-size: 8px; /* match desktop */
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #999;
  }
  /* ── Mobile: keep add-to-route buttons consistent with desktop ── */
  .bs-bookmarks-header-row .route-from-bookmarks-btn,
  .bs-view-list > .route-from-bookmarks-btn,
  #route-from-visible {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ui-fg-70);
    text-align: left;
  }

  /* ── List items — tighter vertical spacing on mobile ── */
  .list-item {
    padding: 3px 12px;
    gap: 4px;
    min-height: 44px;
  }
  .list-item-num {
    margin-right: 4px;
  }

  /* ── Sort row — padding now handled by .bs-bookmarks-header-row ── */
  /* ── Add-to-route buttons — tighter padding ── */
  .bs-bookmarks-header-row .route-from-bookmarks-btn,
  .bs-view-list > .route-from-bookmarks-btn,
  #route-from-visible {
    padding: 6px 12px;
  }

  /* ── Content area (flex child so it fills remaining height; min-height: 0 allows shrink) ── */
  /* Keep scroll area inside sheet so scrollbar doesn't run off screen */
  .bs-content {
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    position: relative;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0));
    box-sizing: border-box;
  }
  /* Keep content non-scrollable so only .bs-view scrolls (single scroll container for list/visited) */
  #bottom-sheet.snap-full .bs-content {
    overflow: hidden;
  }

  /* ── Views (list / detail / route) ── */
  .bs-view {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s;
  }
  .bs-view-list {
    transform: translateX(0);
    opacity: 1;
  }
  /* List body must grow with content so .bs-view-list scrolls (all/fav/visited tabs) */
  .bs-view-list #list-body {
    overflow: visible;
    flex: none;
    min-height: 0;
  }
  /* Sort wrap is now inside .bs-bookmarks-header-row — see that section for styles */
  /* Extra bottom space so last line is fully visible (no half-line cut off) */
  .bs-view-list {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
    box-sizing: border-box;
  }
  .bs-view-list.slide-out {
    transform: translateX(-30%);
    opacity: 0;
    pointer-events: none;
  }
  .bs-view-detail {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
  }
  .bs-view-detail.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
  }
  .bs-view-route {
    transform: translateX(0);
    opacity: 0;
    pointer-events: none;
    display: none;
  }
  .bs-view-route.active {
    opacity: 1;
    pointer-events: auto;
    display: block;
  }

  /* ── Hide panel header (INFO + close) and top-right close in mobile detail ── */
  .bs-detail-content #panel-header { display: none !important; }
  .bs-close { display: none !important; }

  /* ── Close button (detail view) — hidden on mobile; carousel close used instead ── */
  .bs-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .bs-close:active { opacity: 0.6; }

  /* ── Close button inside carousel nav (next to arrows) ── */
  .bs-detail-content .bs-close-carousel { display: flex !important; }
  .bs-close-carousel {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 20px;
    font-family: inherit;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
  }
  .bs-close-carousel:active { opacity: 0.6; }

  /* ── Route tab: bold text when route has stops (underline only when .active) ── */
  .bs-tab-route.has-route {
    color: #000;
  }

  /* ── Route preview bar (peek state) ── */
  .bs-route-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid #eee;
    font-family: inherit;
    flex-shrink: 0;
  }
  .bs-route-preview-text {
    cursor: pointer;
    flex: 1;
    color: #000;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .bs-route-preview-clear {
    background: none;
    border: none;
    color: #000;
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0;
    cursor: pointer;
    margin-left: auto;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
  }
  .bs-route-preview-clear:hover { color: var(--ui-btn-fg-hover); }

  /* ── Detail content inside bottom sheet (single scroll container when #panel-inner is moved here) ── */
  .bs-detail-content {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
  }
  .bs-detail-content #panel-carousel {
    height: 200px;
  }
  .bs-detail-content #panel-body {
    padding: 12px;
    flex: none;
    min-height: auto;
    overflow-y: visible;
  }
  .bs-detail-content #panel-name {
    font-size: 16px;
  }
  .bs-detail-content .panel-footer-label {
    width: auto;
    min-width: 60px;
  }
  .bs-detail-content .panel-footer-row {
    flex-wrap: wrap;
  }
  .bs-detail-content #carousel-caption {
    left: 0;
    flex-wrap: wrap;
  }
  .bs-detail-content #carousel-caption-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    max-height: 3.2em;
    line-height: 1.6;
  }

  /* ── Route view inside bottom sheet ──
   * Same as desktop: summary + actions bar always visible at bottom; only route items scroll. */
  .bs-view-route.active {
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    overflow-y: hidden;
  }
  .bs-view-route #route-section-body {
    max-height: none;
    padding: 8px 12px 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .bs-view-route #route-mode-bar,
  .bs-view-route #route-walk-threshold,
  .bs-view-route #route-summary-row {
    flex-shrink: 0;
  }
  .bs-view-route #route-stops-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
  }
  /* Bottom bar always visible (same as desktop), not scrolled away */
  .bs-view-route #route-actions-bar {
    flex-shrink: 0;
    border-top: 1px solid #e8e8e8;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
    background: #fff;
    margin: 0 -12px 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    z-index: 2;
  }

  /* ── Bookmarks header row (unified toolbar: rfb + sort + share) ── */
  .bs-bookmarks-header-row {
    display: flex;
    align-items: center;
    /* Keep vertical rhythm consistent: tabs → buttons → sort row */
    --bs-header-vgap: 8px;
    row-gap: var(--bs-header-vgap);
    column-gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 5;
    /* Only tighten the gap below the header (between SORT BY and list) */
    padding: var(--bs-header-vgap) 12px 2px;
    min-height: 0;
    box-sizing: border-box;
  }
  /* Mobile: keep primary actions on one line; sort can wrap below */
  .bs-bookmarks-header-row .route-from-bookmarks-btn,
  .bs-bookmarks-header-row #route-from-visible {
    order: 1;
    flex: 0 1 auto; /* size to text (don’t stretch to fill row) */
    width: auto;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Sort row container (right aligned) */
  .bs-bookmarks-toolbar-right {
    order: 2;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    white-space: nowrap;
  }
  .bs-bookmarks-header-row .route-from-bookmarks-btn {
    border-bottom: none;
    padding: 0;
  }
  .bs-bookmarks-header-row .list-export-dropdown {
    order: 1;
    flex: 0 0 auto;
    margin-left: 0;
  }
  .bs-bookmarks-header-row .list-sort-wrap {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 0;
    width: auto;
    flex: 0 0 auto;
    margin-left: 0;
  }
  .bs-bookmarks-header-row .list-export-trigger {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.12em;
    padding: 0;
    min-height: auto;
  }
  .bs-bookmarks-header-row .list-export-menu {
    bottom: auto;
    top: 100%;
    z-index: 10;
  }

  /* Mobile: align sort dropdown to the left edge */
  .is-mobile .list-sort-menu {
    left: 0;
    right: auto;
  }

  /* Mobile: keep SHARE triggers subtle, not boxed buttons */
  .is-mobile .list-export-trigger,
  .is-mobile .route-export-trigger {
    border: none;
    padding: 0;
    background: none;
    color: #999;
  }

  /* Mobile: action buttons match desktop info panel (outlined), but slightly darker */
  .is-mobile #route-from-bookmarks,
  .is-mobile #route-from-visible,
  .is-mobile .bs-bookmarks-header-row #list-export-trigger,
  .is-mobile #route-actions-bar #route-optimize,
  .is-mobile #route-actions-bar #route-gmaps,
  .is-mobile #route-actions-bar #route-export-trigger {
    border: 1px solid #ccc;
    border-radius: 0;
    background: none;
    padding: 4px 10px;
    min-height: 22px;
    line-height: 1;
    color: #666; /* darker than desktop inactive (#999) */
  }

  /* Mobile: route bottom actions — slightly tighter so labels stay on one line */
  .is-mobile #route-actions-bar {
    gap: 8px;
  }
  .is-mobile #route-actions-bar .aalto-btn-outline,
  .is-mobile #route-actions-bar .route-export-trigger {
    font-size: 9px; /* +1px for mobile readability */
    letter-spacing: 0.1em;
    padding: 4px 8px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
  }
  .is-mobile #route-from-bookmarks:hover,
  .is-mobile #route-from-visible:hover,
  .is-mobile .bs-bookmarks-header-row #list-export-trigger:hover,
  .is-mobile #route-actions-bar #route-optimize:hover,
  .is-mobile #route-actions-bar #route-gmaps:hover,
  .is-mobile #route-actions-bar #route-export-trigger:hover {
    border-color: var(--ui-btn-border-active);
    color: #000;
    background: transparent;
  }

  /* Mobile layout: no print, single Share button → system share sheet */
  .is-mobile .list-export-option[data-action="print-bookmarks"],
  .is-mobile .route-export-option[data-action="print-route"] {
    display: none;
  }
  .is-mobile .list-export-menu,
  .is-mobile .route-export-menu {
    display: none !important;
  }
  .is-mobile .list-export-arrow,
  .is-mobile .route-export-arrow {
    display: none;
  }

  /* Hide redundant group headers on mobile — tabs already show filter + count */
  .bs-view-list > #list-body > .list-group-header:first-child {
    display: none;
  }

  /* ── List items touch-friendly sizing ── */
  .list-item {
    padding: 6px 12px;
    gap: 8px;
    min-height: 0;
  }
  .list-item-name {
    font-size: 14px;
  }
  /* Tighter action icons on mobile — closer to each other and content */
  .list-actions {
    gap: 0;
  }
  .list-action-btn {
    padding: 2px;
    min-width: 24px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    color: #aaa;
    border: none;
  }
  .list-action-btn.active {
    background: none;
    color: #000;
  }

  /* ── Filter counts (brackets) ── */
  .bs-tab .bs-count {
    margin-left: 2px;
  }

  /* ── Toast position above bottom sheet ── */
  #toast {
    bottom: 200px;
    bottom: calc(200px + env(safe-area-inset-bottom, 0));
  }

  /* ── Carousel touch-friendly ── */
  #carousel-prev, #carousel-next {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  /* ── Lightbox: ensure on top ── */
  #lightbox { z-index: 200; }
}

/* ── About modal ── */
body.about-open { overflow: hidden; }
.about-modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; }
.about-modal[hidden] { display: none; }
.about-modal-backdrop { position: absolute; inset: 0; background: rgba(255,255,255,0.9); }
.about-modal-inner {
  position: relative;
  background: #fff;
  border: 1px solid #000;
  max-width: 560px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 28px 32px 32px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.about-modal .about-close {
  position: absolute;
  top: 8px; right: 8px;
  background: none; border: 0;
  font-size: 18px; line-height: 1; cursor: pointer; color: #000;
  padding: 6px 8px;
}
.about-modal .about-title {
  margin: 0 0 16px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
}
.about-modal .about-body { font-size: 13px; line-height: 1.55; color: #111; }
.about-modal .about-body p { margin: 0 0 12px; }
.about-modal .about-body p:last-child { margin-bottom: 0; }
.about-modal .about-body a { color: #000; text-decoration: underline; }

#bottom-sheet { bottom: env(safe-area-inset-bottom); }

/* ── Focus-visible (keyboard users) ── */
:where(button, a, [tabindex], input, .list-item, .list-filter-btn, .bs-tab):focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* ── Panel: year line + correction link ── */
.panel-year {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 12px;
  color: #888;
  letter-spacing: 0.05em;
  line-height: 1.7;
  flex-shrink: 0;
}
.panel-correction {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.4;
  color: #888;
}
.panel-correction a { color: #888; text-decoration: underline; text-underline-offset: 2px; }
.panel-correction a:hover { color: #000; }

/* ── Lightbox: per-image credit ── */
#lightbox-credit {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.02em;
  padding: 6px 14px calc(6px + env(safe-area-inset-bottom));
  text-align: center;
  pointer-events: none;
}
#lightbox-credit a { color: #fff; text-decoration: underline; pointer-events: auto; }
#lightbox-credit:empty { display: none; }


