/* Reusable components. Mobile rules are at the end of each block (max-width: 768px). */

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-height);
  z-index: var(--z-topbar);
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand search actions";
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding: 0 var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

/* A menu opened from the top bar (account) must show over the panel */
.topbar:has(.menu[open]) {
  z-index: var(--z-topbar-menu);
}

.topbar__actions {
  grid-area: actions;
  display: flex;
  gap: var(--space-2);
}

.brand {
  grid-area: brand;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}

/* Mobile: search moves to floating buttons over the map (.map-actions) */
@media (max-width: 768px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand actions";
  }
}

/* ---------- Floating over the map: quick filters (+ search buttons on mobile) ---------- */
.map-actions {
  position: fixed;
  top: calc(var(--topbar-height) + var(--space-3));
  left: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  /* The row's empty parts let the map be dragged; only its buttons take clicks */
  pointer-events: none;
}

.map-actions > * {
  pointer-events: auto;
}

/* Desktop: with the panel open, the row ends where the panel starts, so no
   chip hides under it (the rest scroll into view) */
@media (min-width: 769px) {
  body:has(#panel:not([hidden])) .map-actions {
    right: calc(var(--panel-width) + var(--space-4));
  }
}

.map-actions__search {
  display: none;
}

/* Quick filters: one scrolling row, faded at both edges */
.quick-filters {
  display: flex;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-1) var(--space-3);
  overflow-x: auto;
  scrollbar-width: none;
  mask-image: linear-gradient(to right, transparent, #000 var(--space-3), #000 calc(100% - var(--space-3)), transparent);
}

.quick-filters::-webkit-scrollbar {
  display: none;
}

@media (max-width: 768px) {
  .map-actions {
    left: var(--space-3);
    right: 0;
  }

  .map-actions__search {
    display: flex;
    flex: none;
    gap: var(--space-2);
  }
}

/* Pill button over the map (quick filters); pressed = active */
.chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.15);
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.chip .icon {
  color: var(--color-primary);
}

.chip[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-primary-text);
}

.chip[aria-pressed="true"] .icon {
  color: inherit;
}

/* Round icon button floating over the map */
.fab {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--fab-size);
  height: var(--fab-size);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.fab .icon {
  width: 22px;
  height: 22px;
}

.fab--active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-primary-text);
}

/* Count badge, e.g. active filters */
.fab[data-count]::after {
  content: attr(data-count);
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-primary);
  color: var(--color-primary-text);
  font-size: var(--font-size-xs);
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* ---------- Search bar ---------- */
.search-bar {
  grid-area: search;
  justify-self: center;
  width: 100%;
  max-width: 560px;
  display: flex;
  gap: var(--space-2);
}

@media (max-width: 768px) {
  .search-bar {
    display: none;
  }
}

.search-bar__field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-bar__input {
  padding-right: 40px;
}

.search-bar__clear {
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
}

/* ---------- Form controls ---------- */
.input {
  width: 100%;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
}

.input--multiline {
  resize: vertical;
  min-height: 4.5em;
}

.input:disabled {
  background: var(--color-bg);
  cursor: not-allowed;
}

.input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* A small form in place of a value (editable.js): the counter, Cancel and
   Save on one row, almost touching the field */
.form--inline {
  gap: var(--space-1);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field__label {
  padding: 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.field__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.field__row > .input {
  flex: 1 1 140px;
  width: auto;
}

.field__hint {
  color: var(--color-muted);
  font-size: var(--font-size-xs);
}

.field__hint {
  margin: 0;
}

.field__hint--ok {
  color: var(--color-success);
}

.field__hint--error {
  color: var(--color-danger);
}

/* Checkbox with its label to the right */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  cursor: pointer;
}

.checkbox input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--color-primary);
}

.form__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
}

/* A secondary link on the left, the main button on the right */
.form__actions--spread {
  justify-content: space-between;
}

.form__error {
  margin: 0;
  color: var(--color-danger);
  font-size: var(--font-size-sm);
}

.form__note {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
}

.btn--ghost {
  border-color: var(--color-border);
  background: var(--color-surface);
}

.btn--danger {
  border-color: var(--color-danger);
  background: var(--color-surface);
  color: var(--color-danger);
}

.btn--icon {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: var(--font-size-lg);
  line-height: 1;
}

/* Panel Back and Close: larger glyphs, easy to see */
.panel__nav {
  width: 44px;
  height: 44px;
  font-size: var(--font-size-nav);
}

/* Icons inside buttons and links follow the text size */
.icon {
  flex: none;
  width: 1.15em;
  height: 1.15em;
}

/* Inline text that acts like a link (hashtags) */
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-primary);
  cursor: pointer;
}

/* ---------- Text helpers ---------- */
.section-label {
  margin: var(--space-4) 0 0;
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.empty {
  color: var(--color-muted);
}

/* ---------- Map ---------- */
.map {
  position: fixed;
  inset: var(--topbar-height) 0 0 0;
  z-index: var(--z-map);
}

/* Marker: MapLibre moves .marker, .pin draws the shape */
.marker {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.marker--active {
  z-index: 1;
}

.pin {
  display: block;
  width: var(--pin-size);
  height: var(--pin-size);
  border: 2px solid var(--color-surface);
  border-radius: 50% 50% 50% 0;
  background: var(--color-primary);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.3);
  /* The rotated tip sits below the box; lift it onto the anchor point */
  transform: translateY(-6px) rotate(-45deg);
  transition: transform 0.15s;
}

.pin--list {
  background: var(--color-list);
}

/* Category icon inside a pin (first tag matching a quick filter), kept upright */
.pin__icon {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--color-surface);
  transform: rotate(45deg);
}

.pin__icon .icon {
  width: 60%;
  height: 60%;
}

.marker--active .pin {
  transform: translateY(-10px) rotate(-45deg) scale(1.35);
}

.map-tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  transform: translate(-50%, -100%);
  max-width: 240px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
  background: var(--color-text);
  color: var(--color-primary-text);
  font-size: var(--font-size-sm);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Panel: right side on desktop, full screen on mobile ---------- */
.panel {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  bottom: 0;
  width: var(--panel-width);
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

/* Slid down to the bottom edge while placing a location on mobile */
.panel {
  transition: transform 0.3s ease, height 0.3s ease;
}

/* While the sheet follows a finger, no easing */
.panel--dragging {
  transition: none;
}

.panel[shelved] {
  transform: translateY(calc(100% - var(--shelf-height)));
}

.panel__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

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

.panel__title {
  margin: 0;
  font-size: var(--font-size-lg);
  /* Up to two lines, then cut with an ellipsis */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* Shown only in a collapsed mobile sheet (see the mobile rules) */
.panel__peek {
  display: none;
  margin: 0;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.panel__subtitle {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-4);
}

/* Drag handle of the mobile sheet: a wide tap area with a small bar drawn in it */
.panel__grabber {
  display: none;
  width: 100%;
  height: 20px;
  padding: 0;
  border: 0;
  background: none;
  cursor: grab;
  touch-action: none;
}

.panel__grabber::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  margin: 0 auto;
  border-radius: 2px;
  background: var(--color-border);
}

@media (max-width: 768px) {
  .panel {
    top: 0;
    width: 100%;
  }

  /* Sheet: bottom half panel, its view fills the body (no outer scroll) */
  .panel[sheet] {
    top: auto;
    height: var(--sheet-height);
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  }

  .panel[sheet] .panel__grabber {
    display: block;
  }

  /* Expanded sheet: full screen, every slide shows the full details */
  .panel[sheet][sheet-state="expanded"] {
    height: 100dvh;
    border-radius: 0;
  }

  /* Collapsed sheet: only the header; the peek text (dates) replaces the subtitle */
  .panel[sheet][sheet-state="collapsed"] {
    height: auto;
  }

  .panel[sheet][sheet-state="collapsed"] .panel__body {
    display: none;
  }

  .panel[sheet][sheet-state="collapsed"] .panel__peek:not([hidden]) {
    display: block;
  }

  .panel[sheet][sheet-state="collapsed"][has-peek] .panel__subtitle {
    display: none;
  }

  /* Floating buttons at half height (a pin with Back): only Back, no Close
     (tapping the map closes the sheet), and the card starts below it */
  .panel[sheet][header="buttons"][sheet-state="half"] .panel__close {
    display: none;
  }

  .panel[sheet][header="buttons"][sheet-state="half"] .panel__body {
    padding-top: var(--space-5);
  }

  /* The pin view fills the sheet, so its slide scrolls (as a list's does) */
  .pin-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .panel[sheet-state="expanded"] .carousel__slide > .card {
    display: none;
  }

  .panel[sheet-state="expanded"] .carousel__full {
    display: flex;
  }

  .panel[sheet] .panel__body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .panel[sheet] .panel__view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
}

/* Header modes (pw-panel.js updateHeader): none hides it; buttons drops the
   title row and floats Back and Close over the top of the body, beside the
   view's own title */
.panel[header="none"] .panel__header {
  display: none;
}

.panel[header="buttons"] .panel__header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  padding: 0 var(--space-2);
  border-bottom: 0;
  pointer-events: none;
}

.panel[header="buttons"] .panel__header > * {
  pointer-events: auto;
}

.panel[header="buttons"] .panel__heading {
  display: none;
}

.panel[header="buttons"] .panel__close {
  margin-left: auto;
}

.panel[header="buttons"] .panel__body {
  padding-top: var(--space-2);
}

/* The view's title leaves room for the floating buttons */
.panel[header="buttons"]:has(.panel__back:not([hidden])) .detail__title {
  padding-left: 40px;
}

/* Card parts only shown on a mobile sheet's slide (see there) */
.card__owner,
.card__actions,
.card__tags {
  display: none;
}

/* A pin on its own (pin-detail.js) on desktop: its full view, as on the
   mobile sheet at full height */
@media (min-width: 769px) {
  .pin-view .carousel__slide > .card {
    display: none;
  }

  .pin-view .carousel__full {
    display: flex;
  }
}

/* Round icon buttons (a pin's Route to, Add to calendar, Share; More info on
   its card); the labels stay for screen readers */
.icon-actions .btn {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}

.icon-actions .btn__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Full view: the round icons, then More info with its label, on one row */
.detail__buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* Round icon buttons in the full view (the card's are placed by the slide grid) */
.detail .icon-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* @owner under the dates, small, as on the card */
.detail__by {
  margin: 0;
  font-size: var(--font-size-xs);
}

/* Full view of a pin on mobile: its own title at the top, leaving room on
   the right for the sheet's × */
.detail__title {
  margin: 0;
  padding-right: 44px;
  font-size: var(--font-size-lg);
}

/* ---------- Detail: shared body of pin and list panels ---------- */
.detail {
  --detail-gap: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--detail-gap);
}

/* @owner belongs with the dates: a small gap after them */
.detail__when + .detail__by {
  margin-top: calc(var(--space-1) - var(--detail-gap));
}

.detail > * {
  margin: 0;
}

/* The owner link, in the details or in the panel header */
.panel__subtitle a {
  color: var(--color-muted);
}

.detail__image {
  width: 100%;
  aspect-ratio: var(--image-ratio);
  object-fit: cover;
  border-radius: var(--radius);
}

.detail__image--wide {
  aspect-ratio: var(--image-ratio-wide);
}

.detail__when {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.detail__description {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* Mobile: smaller text and spacing, so details need less scrolling */
@media (max-width: 768px) {
  .detail {
    --detail-gap: var(--space-2);
  }

  .detail__description,
  .profile__bio {
    font-size: var(--font-size-sm);
  }
}

.detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.detail__actions:empty {
  display: none;
}

/* ---------- Tags ---------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag {
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: 999px;
  background: var(--color-border);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  cursor: pointer;
}

.tag--selected {
  background: var(--color-primary);
  color: var(--color-primary-text);
}

.tags:empty {
  display: none;
}

/* ---------- Card: pin or list summary; the whole card opens it ---------- */
.card {
  position: relative;
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.card__thumb {
  flex: none;
  width: var(--thumb-size);
  height: var(--thumb-size);
  border-radius: calc(var(--radius) - 2px);
  background: var(--color-border);
  object-fit: cover;
}

.card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.card__body > * {
  margin: 0;
}

.card__title {
  font-size: var(--font-size-md);
  overflow-wrap: anywhere;
}

/* The title link covers the whole card, so the card opens the item */
.card__link {
  color: inherit;
  text-decoration: none;
}

.card__link::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card:has(.card__link:hover) {
  border-color: var(--color-primary);
}

.card:has(.card__link:focus-visible) {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.card__link:focus-visible {
  outline: none;
}

/* A card's "View list" button: only on a mobile sheet's slide, where the card
   is no link (the expanded sheet's full entry keeps its own, see collection.js) */
.card .card__open {
  display: none;
}

.carousel__full .card__open {
  align-self: flex-start;
}

/* Small kind label after the title, e.g. "List" */
.card__label {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 0 var(--space-2);
  border-radius: 999px;
  background: var(--color-list);
  color: var(--color-text);
  font-size: var(--font-size-xs);
  font-weight: 600;
  vertical-align: middle;
}

.card__meta {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.card__text {
  font-size: var(--font-size-sm);
}

.card__text--full {
  display: none;
}

/* A plain vertical list of cards (profile tabs) */
.card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Ended items on your own profile */
.card--inactive {
  opacity: 0.45;
}

/* ---------- Tabs ---------- */
.tabs__list {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.tabs__tab {
  margin-bottom: -1px;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
}

.tabs__tab[aria-selected="true"] {
  border-bottom-color: var(--color-primary);
  color: var(--color-text);
}

/* ---------- Carousel: stack on desktop, swipe on mobile ---------- */
.carousel__track {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Indicator and swipe hint exist for the mobile carousel only */
.carousel__dots,
.carousel__counter,
.carousel__hint {
  display: none;
}

@media (max-width: 768px) {
  .carousel {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .carousel__track {
    flex: 1;
    min-height: 0;
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .carousel__track::-webkit-scrollbar {
    display: none;
  }

  .carousel__dots {
    display: flex;
    justify-content: center;
    gap: var(--space-1);
    padding-top: var(--space-2);
  }

  /* Small dot with a larger tap area */
  .carousel__dot {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    background: radial-gradient(circle, var(--color-border) 4px, transparent 4.5px);
    cursor: pointer;
  }

  .carousel__dot[aria-current] {
    background: radial-gradient(circle, var(--color-primary) 4px, transparent 4.5px);
  }

  .carousel__counter {
    display: block;
    margin: 0;
    padding-top: var(--space-2);
    color: var(--color-muted);
    font-size: var(--font-size-sm);
    text-align: center;
  }

  .carousel__hint {
    display: block;
    position: absolute;
    right: 0;
    bottom: var(--space-5);
    margin: 0;
    padding: var(--space-2) var(--space-3);
    border-radius: 999px;
    background: var(--color-text);
    color: var(--color-primary-text);
    font-size: var(--font-size-sm);
    pointer-events: none;
    animation: carousel-hint-blink 1.2s ease-in-out infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    .carousel__hint {
      animation: none;
    }
  }

  .carousel__slide {
    flex: 0 0 100%;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  /* A card on its own slide: no frame, bigger thumbnail with title, dates and
     the View button beside it, then the full description across the width */
  .carousel__slide > .card {
    --thumb-size: var(--thumb-size-lg);
    display: grid;
    grid-template-columns: var(--thumb-size) 1fr;
    grid-template-rows: auto auto auto 1fr auto auto;
    grid-template-areas:
      "thumb title"
      "thumb meta"
      "thumb owner"
      "thumb actions"
      "text text"
      "tags tags";
    gap: var(--space-1) var(--space-3);
    padding: 0;
    border: 0;
  }

  /* Without an image: everything stacked, no empty column */
  .carousel__slide > .card--no-image {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(6, auto);
    grid-template-areas:
      "title"
      "meta"
      "owner"
      "actions"
      "text"
      "tags";
  }

  .carousel__slide > .card .card__owner {
    grid-area: owner;
    display: block;
    font-size: var(--font-size-xs);
  }

  /* A pin's buttons as round icons (labels kept for screen readers) */
  .carousel__slide > .card .card__actions {
    grid-area: actions;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-self: end;
  }


  /* Tags as pills on one line that scrolls sideways */
  .carousel__slide > .card .card__tags {
    grid-area: tags;
    display: block;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .card__tags .tags {
    flex-wrap: nowrap;
  }

  .card__tags .tags > li {
    flex: none;
  }

  .carousel__slide > .card--no-image .card__thumb {
    display: none;
  }

  .carousel__slide > .card .card__body {
    display: contents;
  }

  .carousel__slide > .card .card__title {
    grid-area: title;
    font-size: var(--font-size-md);
  }

  /* A slide is not a link: a pin's slide is its own view (with its own
     buttons and links), a list's slide has its "View list" button */
  .carousel__slide > .card .card__link {
    pointer-events: none;
  }

  .carousel__slide > .card .card__link::after {
    content: none;
  }

  .carousel__slide > .card .card__open {
    display: inline-flex;
    grid-area: actions;
    align-self: end;
    justify-self: start;
  }

  /* The image grows with the column beside it (long titles), never below its square size */
  .carousel__slide > .card .card__thumb {
    grid-area: thumb;
    align-self: stretch;
    height: auto;
    min-height: var(--thumb-size);
  }

  .carousel__slide > .card .card__meta {
    grid-area: meta;
  }

  .carousel__slide > .card .card__text--short {
    display: none;
  }

  .carousel__slide > .card .card__text--full {
    grid-area: text;
    display: block;
    margin-top: var(--space-2);
    font-size: var(--font-size-sm);
    white-space: pre-line;
    overflow-wrap: anywhere;
  }
}

@keyframes carousel-hint-blink {
  50% {
    opacity: 0.35;
  }
}

/* ---------- Menu: dropdown selector ---------- */
.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu__list {
  position: absolute;
  z-index: 1;
  min-width: 100%;
  width: max-content;
  margin: var(--space-1) 0 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.menu--end .menu__list {
  right: 0;
}

/* Avatar button that opens the account menu */
.account-button {
  display: block;
  border-radius: 50%;
  cursor: pointer;
}

.account-button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  color: var(--color-text);
  font-size: var(--font-size-sm);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

/* Product icons (Google Maps, Outlook...) in menus: a bit larger, shape kept */
.icon--product {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.menu__item:hover {
  background: var(--color-bg);
}

/* ---------- Avatar: initials on the user's color ---------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: 50%;
  background: var(--avatar-color, var(--color-muted));
  color: #ffffff;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
}

/* Shift measured from the device's font in avatar.js, so capitals are centered */
.avatar__text {
  transform: translateY(var(--avatar-text-shift, 0));
}

.avatar--sm {
  width: 36px;
  height: 36px;
  font-size: var(--font-size-sm);
}

.avatar--lg {
  width: 96px;
  height: 96px;
  font-size: 2rem;
}

/* ---------- Profile ---------- */
.profile {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
}

.profile > .tabs,
.profile > .editable {
  justify-self: stretch;
}

/* Avatar with the name and @username beside it; room for the floating Close
   (and Back, when shown) of the panel's buttons header */
.profile__identity {
  justify-self: stretch;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-right: 44px;
}

.panel[header="buttons"]:has(.panel__back:not([hidden])) .profile__identity {
  padding-left: 40px;
}

.profile__names {
  min-width: 0;
}

.profile__names > *,
.profile__names .editable > p {
  margin: 0;
}

.profile__name {
  font-size: var(--font-size-lg);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.profile__username {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
  overflow-wrap: anywhere;
}

/* ---------- Editable text: label, value and a pencil after its last character ---------- */
.editable {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.editable > p {
  margin: 0;
}

.editable__edit {
  width: 28px;
  height: 28px;
  color: var(--color-muted);
  vertical-align: middle;
}

.editable__edit .icon {
  width: 16px;
  height: 16px;
}

.profile > * {
  margin: 0;
}


.profile__bio {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.profile__website {
  overflow-wrap: anywhere;
}

/* ---------- Editing pins and lists ---------- */

/* Circle fixed at the center of the visible map: the location is under it */
.location-picker {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  pointer-events: none;
  width: var(--pin-size);
  height: var(--pin-size);
  border: 3px solid var(--color-surface);
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 0 6px rgb(37 99 235 / 0.25), var(--shadow);
}

/* Search buttons step aside while editing */
.is-editing .map-actions {
  display: none;
}

/* Mobile: "place it, then confirm" bar at the bottom */
.placement-bar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: var(--z-placement);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

/* Above the slid-down panel */
body:has(.panel[shelved]) .placement-bar {
  bottom: var(--shelf-height);
}

.placement-bar__text {
  margin: 0;
  font-size: var(--font-size-sm);
}

.placement-bar__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.image-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.image-field__preview {
  width: 100%;
  aspect-ratio: var(--image-ratio);
  object-fit: cover;
  border-radius: var(--radius);
}

.image-field__file {
  flex: 1 1 200px;
  min-width: 0;
  font-size: var(--font-size-sm);
}

.tag-input {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Delete, separated from the rest of the form */
.form__danger {
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.confirm {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.confirm__text {
  margin: 0;
  color: var(--color-danger);
  font-size: var(--font-size-sm);
}

/* Drag to reorder */
.sortable {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.sortable__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.sortable__row--dragging {
  box-shadow: var(--shadow);
  opacity: 0.85;
}

.sortable__handle {
  padding: var(--space-1) var(--space-2);
  border: 0;
  background: none;
  color: var(--color-muted);
  font-size: var(--font-size-lg);
  cursor: grab;
  /* Dragging on touch screens must not scroll the page or select text */
  touch-action: none;
  user-select: none;
}

.sortable__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-add {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

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

.carousel__footer {
  padding-top: var(--space-3);
}

@media (max-width: 768px) {
  .list-add {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

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

.carousel__footer {
    display: flex;
    justify-content: center;
    padding-top: var(--space-2);
  }
}

/* Full details of a collection entry, shown in the expanded mobile sheet */
.carousel__full {
  display: none;
  flex-direction: column;
  gap: var(--space-2);
}

.carousel__full-title {
  margin: 0;
  font-size: var(--font-size-lg);
}

/* ---------- User location ---------- */

/* "My location" button, in the map's control group above the zoom buttons.
   MapLibre's own button rules are more specific, hence the doubled class. */
.maplibregl-ctrl-group .locate-button {
  display: flex;
  align-items: center;
  justify-content: center;
}

.locate-button .icon {
  width: 18px;
  height: 18px;
  color: var(--color-text);
}

.locate-button:disabled .icon {
  color: var(--color-muted);
}

/* The user's position: a blue dot with a soft pulse, on a faint circle the
   size of the position's uncertainty (--accuracy-size, set from the map) */
.user-location {
  position: relative;
  width: 16px;
  height: 16px;
}

.user-location__accuracy {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--accuracy-size, 0);
  height: var(--accuracy-size, 0);
  border: 1px solid rgb(37 99 235 / 0.35);
  border-radius: 50%;
  background: rgb(37 99 235 / 0.12);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.user-location__dot {
  position: relative;
  width: 16px;
  height: 16px;
  border: 3px solid var(--color-surface);
  border-radius: 50%;
  background: var(--color-user-location);
  box-shadow: 0 0 0 0 rgb(37 99 235 / 0.45), 0 1px 4px rgb(0 0 0 / 0.3);
  animation: user-dot-pulse 2s ease-out infinite;
}

@keyframes user-dot-pulse {
  70% {
    box-shadow: 0 0 0 14px rgb(37 99 235 / 0), 0 1px 4px rgb(0 0 0 / 0.3);
  }
  100% {
    box-shadow: 0 0 0 0 rgb(37 99 235 / 0), 0 1px 4px rgb(0 0 0 / 0.3);
  }
}

/* Rough position (over LOCATION_DOT_MAX_ACCURACY_M): only the circle */
.user-location--rough .user-location__dot {
  visibility: hidden;
}

.user-location--unknown {
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .user-location__dot {
    animation: none;
  }
}

/* ---------- When (pin dates): date, From → To on one line ---------- */
.when-field select.input {
  appearance: auto;
}

.when-field__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* The date takes the whole first line */
.when-field .date-picker {
  flex: 1 1 100%;
}

/* ---------- Date picker: a date button, its calendar drops down under it,
   inside the field, so it scrolls with the panel ---------- */
.date-picker {
  position: relative;
}

.date-picker__button {
  text-align: left;
  cursor: pointer;
}

.date-picker__dropdown {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  z-index: 5;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

/* The calendar inside the dropdown: no frame of its own */
.date-picker__dropdown .air-datepicker {
  border: 0;
}

/* The library greys the year next to the month; here it would look disabled */
.date-picker__dropdown .air-datepicker-nav--title i {
  color: inherit;
}

/* "Several days" switch under the calendar */
.date-picker__several {
  display: flex;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-border);
}

.date-picker__buttons {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
}

.when-field__row > select {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

.when-field__arrow {
  color: var(--color-muted);
}

.date-picker__note {
  max-width: 246px;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: var(--font-size-xs);
}

/* air-datepicker (calendar of the date picker) in the site's colors and font */
.air-datepicker {
  --adp-font-family: var(--font-base);
  --adp-accent-color: var(--color-primary);
  --adp-cell-background-color-selected: var(--color-primary);
  --adp-cell-background-color-selected-hover: var(--color-primary);
  --adp-border-radius: var(--radius);
  --adp-z-index: var(--z-tooltip);
}

/* Two or more options as one switch (Pin / List) */
.segmented {
  display: inline-flex;
  align-self: flex-start;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented__option {
  position: relative;
  cursor: pointer;
}

.segmented__option input {
  position: absolute;
  opacity: 0;
}

.segmented__option span {
  display: block;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
}

.segmented__option:has(input:checked) span {
  background: var(--color-primary);
  color: var(--color-primary-text);
}

.segmented__option:has(input:focus-visible) span {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}
