/* ==========================================================================
   TrailTracker v2 — main app
   Mobile-first. Light hiking look: warm neutrals, orange accent, clean cards.
   ========================================================================== */

:root {
  --accent:        #ff6a00;
  --accent-dark:   #e05c00;
  --accent-soft:   #fff1e6;

  --gold:          #d99b0a;
  --gold-soft:     #fff6de;

  --ink:           #1d1c1a;
  --ink-muted:     #6b6862;
  --ink-faint:     #9a968e;

  --surface:       #ffffff;
  --surface-sunk:  #f5f3ef;
  --page:          #f7f6f3;
  --hairline:      #e7e3dc;

  --danger:        #d1443b;
  --danger-soft:   #fdeceb;
  --track-blue:    #2f6fd0;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;

  --shadow-card: 0 1px 2px rgba(29, 28, 26, .06), 0 6px 20px rgba(29, 28, 26, .10);
  --shadow-fab:  0 2px 6px rgba(29, 28, 26, .16), 0 8px 24px rgba(29, 28, 26, .18);
  --shadow-pop:  0 10px 40px rgba(29, 28, 26, .22);

  /* Safe-area shorthands so overlays clear phone notches / home indicators. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

/* Our own `display` rules out-specify the UA's [hidden] rule, so restate it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.muted { color: var(--ink-faint); }

svg.stroke-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Roundel logo, shared by the boot splash / login card / app bar. */
.boot__mark svg circle,
.auth-card__mark svg circle,
.appbar__mark svg circle { fill: var(--accent); }

.boot__mark svg path,
.auth-card__mark svg path,
.appbar__mark svg path {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
}

.page {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* --------------------------------------------------------------------------
   Boot splash
   -------------------------------------------------------------------------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 20px;
  background: var(--page);
}

.boot__mark svg { width: 54px; height: 54px; display: block; }

.boot__spinner,
.btn.is-busy::after,
.fab__spinner {
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.boot__spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--hairline);
  border-top-color: var(--accent);
}

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

/* --------------------------------------------------------------------------
   Buttons + form fields
   -------------------------------------------------------------------------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}

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

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

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn--ghost {
  background: var(--surface);
  border-color: var(--hairline);
  color: var(--ink);
}
.btn--ghost:hover:not(:disabled) { background: var(--surface-sunk); }

.btn--quiet {
  background: transparent;
  color: var(--ink-muted);
}
.btn--quiet:hover:not(:disabled) { background: var(--surface-sunk); color: var(--ink); }

.btn--block { width: 100%; }
.btn--sm { padding: 8px 14px; font-size: 13.5px; }

.btn:disabled { cursor: default; opacity: .75; }

.btn.is-busy { color: transparent; opacity: 1; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
}
.btn--ghost.is-busy::after,
.btn--quiet.is-busy::after {
  border-color: var(--hairline);
  border-top-color: var(--accent);
}

.field {
  display: block;
  margin-bottom: 14px;
  text-align: left;
}

.field__label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-muted);
}

.field__optional {
  font-weight: 500;
  color: var(--ink-faint);
}

.field__input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field__hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-faint);
}

.form-error {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
}

.placeholder {
  margin: 0;
  padding: 26px 8px;
  font-size: 14px;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Auth pages (login + forced password change)
   -------------------------------------------------------------------------- */

.page--auth {
  display: grid;
  place-items: center;
  padding: calc(var(--safe-t) + 20px) calc(var(--safe-r) + 18px)
           calc(var(--safe-b) + 20px) calc(var(--safe-l) + 18px);
  overflow-y: auto;
  background: var(--page);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 30px 26px 24px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.auth-card__mark { margin-bottom: 14px; }
.auth-card__mark svg { width: 48px; height: 48px; }

.auth-card__mark--key svg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-card__title {
  margin: 0 0 4px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.auth-card__sub {
  margin: 0 0 22px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-muted);
}

.auth-card .btn--block + .btn--block { margin-top: 8px; }

.auth-card__note {
  margin: 16px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-faint);
}

/* --------------------------------------------------------------------------
   Home: app bar, user menu, challenge cards
   -------------------------------------------------------------------------- */

.page--home {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--page);
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + 16px) 12px calc(var(--safe-l) + 16px);
  background: rgba(247, 246, 243, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--hairline);
}

.appbar__brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.appbar__mark svg { width: 24px; height: 24px; display: block; }

.usermenu { position: relative; flex: 0 0 auto; }

.usermenu__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 190px;
  padding: 5px 9px 5px 5px;
  border: 1px solid var(--hairline);
  border-radius: 99px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.usermenu__btn:hover { background: var(--surface-sunk); }
.usermenu__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.usermenu__avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
}

.usermenu__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usermenu__chev { width: 15px; height: 15px; color: var(--ink-faint); flex: 0 0 auto; }

.usermenu__pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 9;
  min-width: 190px;
  padding: 6px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: menu-in .14s var(--ease);
}

@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }

.usermenu__pop button,
.usermenu__pop a {
  display: block;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.usermenu__pop button:hover,
.usermenu__pop a:hover { background: var(--surface-sunk); }

.home {
  max-width: 940px;
  margin: 0 auto;
  padding: 20px calc(var(--safe-r) + 16px) calc(var(--safe-b) + 44px) calc(var(--safe-l) + 16px);
}

.home__section + .home__section { margin-top: 30px; }

.section-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 620px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

.challenge-card {
  display: block;
  width: 100%;
  padding: 16px 17px 15px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
}

.challenge-card--mine {
  cursor: pointer;
  transition: transform .14s var(--ease), box-shadow .14s var(--ease);
}

.challenge-card--mine:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(29, 28, 26, .07), 0 12px 28px rgba(29, 28, 26, .13);
}

.challenge-card--mine:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.challenge-card__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.challenge-card__name {
  flex: 1;
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.challenge-card__percent {
  flex: 0 0 auto;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.challenge-card__desc {
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-muted);

  /* Truncate long descriptions to keep the cards on an even grid. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.challenge-card .progress-bar { margin-top: 12px; }

.challenge-card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
  font-size: 13px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.challenge-card__go {
  margin-left: auto;
  font-weight: 650;
  color: var(--accent);
}

.challenge-card .dot { color: var(--ink-faint); }

.challenge-card .btn { margin-top: 13px; }

/* --------------------------------------------------------------------------
   Challenge map page
   -------------------------------------------------------------------------- */

.page--map { overflow: hidden; }

#map {
  position: absolute;
  inset: 0;
}

/* Keep MapLibre's own controls inside the safe area. Attribution is moved to the
   bottom-left in app.js so it never sits underneath the FAB stack. */
.maplibregl-ctrl-bottom-left {
  margin-bottom: calc(var(--safe-b) + 2px);
  margin-left: var(--safe-l);
}

.maplibregl-ctrl-top-right {
  margin-top: calc(var(--safe-t) + 2px);
  margin-right: var(--safe-r);
}

.stats-card {
  position: absolute;
  top: calc(var(--safe-t) + 12px);
  left: calc(var(--safe-l) + 12px);
  z-index: 5;

  min-width: 200px;
  max-width: min(280px, calc(100vw - 24px));
  padding: 11px 16px 15px 11px;

  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.stats-card__top {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stats-card__label {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-card__percent {
  margin: 2px 0 0 5px;
  font-size: 34px;
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.stats-card__distance {
  margin-left: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  margin-top: 11px;
  height: 5px;
  border-radius: 99px;
  background: var(--surface-sunk);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #ff9248);
  transition: width .25s var(--ease);
}

.stats-card .progress-bar { margin-left: 5px; }

/* --------------------------------------------------------------------------
   Floating action buttons
   -------------------------------------------------------------------------- */

.fab-stack {
  position: absolute;
  right: calc(var(--safe-r) + 14px);
  bottom: calc(var(--safe-b) + 20px);
  z-index: 6;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.fab {
  display: grid;
  place-items: center;
  position: relative;
  border: 0;
  border-radius: 50%;
  box-shadow: var(--shadow-fab);
  cursor: pointer;
  transition: transform .12s var(--ease), background-color .15s var(--ease);
}

.fab:active { transform: scale(.94); }
.fab:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.fab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fab--primary { width: 58px; height: 58px; background: var(--accent); color: #fff; }
.fab--primary:hover { background: var(--accent-dark); }

.fab--secondary { width: 46px; height: 46px; background: var(--surface); color: var(--ink); }
.fab--secondary:hover { background: var(--surface-sunk); }
.fab--secondary svg { width: 21px; height: 21px; }

/* Uploading state: swap the plus glyph for a spinner. */
.fab__spinner {
  display: none;
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(255, 255, 255, .38);
  border-top-color: #fff;
}

.fab.is-busy { cursor: progress; }
.fab.is-busy .fab__icon { visibility: hidden; }
.fab.is-busy .fab__spinner { display: block; }

/* --------------------------------------------------------------------------
   Photo-location picking banner
   -------------------------------------------------------------------------- */

/* The FABs would sit under the banner and invite the wrong tap, so they step
   aside for the duration of the pick. */
.page--map.is-picking .fab-stack { display: none; }

.pick-bar {
  position: absolute;
  z-index: 12;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 22px);
  max-width: calc(100vw - 28px);

  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 16px;
  border-radius: 99px;
  background: rgba(29, 28, 26, .93);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: var(--shadow-fab);
}

.pick-bar .btn { flex: 0 0 auto; }
.pick-bar .btn--quiet { color: #ffd0ab; }
.pick-bar .btn--quiet:hover { background: rgba(255, 255, 255, .14); color: #fff; }

/* --------------------------------------------------------------------------
   Drawer — bottom half-sheet on mobile, right rail on desktop
   -------------------------------------------------------------------------- */

.drawer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(29, 28, 26, .34);
  opacity: 0;
  transition: opacity .22s var(--ease);
}

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

.drawer {
  position: absolute;
  z-index: 11;
  display: flex;
  flex-direction: column;
  background: var(--surface);

  /* mobile: bottom sheet */
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 68dvh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -8px 34px rgba(29, 28, 26, .20);

  transform: translateY(102%);
  transition: transform .26s var(--ease);
}

.drawer.is-open { transform: translateY(0); }

.drawer__header {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 12px 18px;
  border-bottom: 1px solid var(--hairline);
}

.drawer__grabber {
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--hairline);
}

.drawer__title {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.drawer__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-b) + 10px);
}

.drawer__empty {
  margin: 0;
  padding: 30px 20px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-faint);
  line-height: 1.5;
}

@media (min-width: 720px) {
  .drawer {
    left: auto;
    top: 0;
    bottom: 0;
    right: 0;
    width: 380px;
    max-height: none;
    border-radius: 0;
    box-shadow: -8px 0 34px rgba(29, 28, 26, .16);
    transform: translateX(102%);
  }

  .drawer.is-open { transform: translateX(0); }
  .drawer__grabber { display: none; }
  .drawer__header { padding-top: calc(var(--safe-t) + 18px); }
}

/* --------------------------------------------------------------------------
   Activity rows
   -------------------------------------------------------------------------- */

.activity {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 13px 12px 13px 18px;
  border-bottom: 1px solid var(--hairline);
}

.activity:last-child { border-bottom: 0; }

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

.activity__name {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.activity__meta {
  margin-top: 3px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.activity__dot { color: var(--ink-faint); }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}

.activity__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
}

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background-color .13s var(--ease), color .13s var(--ease);
}

.icon-btn:hover { background: var(--surface-sunk); color: var(--ink); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn.is-active { color: var(--track-blue); background: #eaf1fc; }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn--sm { width: 26px; height: 26px; }
.icon-btn--sm svg { width: 14px; height: 14px; }

.icon-btn--back {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin-left: -3px;
  color: var(--ink);
}

.icon-btn__badge {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}

/* Inline delete confirmation replaces the row's action cluster. */
.confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.confirm__text { white-space: nowrap; }

.confirm__btn {
  padding: 5px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.confirm__btn--danger {
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}

.confirm__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.activity.is-deleting { opacity: .45; pointer-events: none; }

/* --------------------------------------------------------------------------
   Map markers + popups
   -------------------------------------------------------------------------- */

/* Objective pin. MapLibre owns `transform` on the marker root, so the rotated
   teardrop lives on an inner element. */
.obj-pin {
  position: relative;
  width: 30px;
  height: 38px;
  cursor: pointer;
}

.obj-pin:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.obj-pin__body {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #b9b5ad;
  box-shadow: 0 2px 6px rgba(29, 28, 26, .35);
  transition: background-color .2s var(--ease);
}

.obj-pin__body svg {
  width: 15px;
  height: 15px;
  transform: rotate(45deg);
  fill: #fff;
  opacity: .9;
}

.obj-pin__body.is-visited {
  background: linear-gradient(140deg, #ffd257, var(--gold));
  box-shadow: 0 2px 6px rgba(217, 155, 10, .5);
}

.obj-pin__body.is-visited svg { fill: #fff; opacity: 1; }

.photo-pin {
  width: 42px;
  height: 42px;
  cursor: pointer;
}

.photo-pin:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 50%; }

.photo-pin__img {
  display: block;
  width: 100%;
  height: 100%;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--surface-sunk) center / cover no-repeat;
  box-shadow: 0 2px 8px rgba(29, 28, 26, .35);
}

.maplibregl-popup-content {
  padding: 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  font-family: inherit;
  overflow: hidden;
}

.popup { padding: 10px 13px; }
.popup__img + .popup__title,
.popup__img + .popup__body { padding-top: 0; }

.popup__img {
  display: block;
  width: calc(100% + 26px);
  margin: -10px -13px 9px;
  max-height: 150px;
  object-fit: cover;
}

.popup__title {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
  color: var(--ink);
}

.popup__body {
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-muted);
  max-width: 220px;
  overflow-wrap: anywhere;
}

.popup__tag {
  display: inline-block;
  margin-top: 7px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-sunk);
  color: var(--ink-muted);
  font-size: 11.5px;
  font-weight: 650;
}

.popup__tag--gold { background: var(--gold-soft); color: #96690a; }

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(29, 28, 26, .42);
  opacity: 0;
  transition: opacity .2s var(--ease);
}

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

.modal {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 50%;
  width: min(400px, calc(100vw - 28px));
  max-height: min(86dvh, calc(100dvh - var(--safe-t) - var(--safe-b) - 24px));

  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);

  opacity: 0;
  transform: translate(-50%, -50%) scale(.97);
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}

.modal.is-open { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.modal--wide { width: min(660px, calc(100vw - 28px)); }

.modal__header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 17px 12px 13px 20px;
  border-bottom: 1px solid var(--hairline);
}

.modal__header > div { flex: 1; min-width: 0; }

.modal__title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.015em;
}

.modal__sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px calc(var(--safe-b) + 20px);
}

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

/* --------------------------------------------------------------------------
   Photos modal
   -------------------------------------------------------------------------- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.photo-grid .placeholder {
  grid-column: 1 / -1;
  text-align: center;
}

.photo {
  position: relative;
  margin: 0;
  border-radius: var(--radius-md);
  background: var(--surface-sunk);
  overflow: hidden;
}

.photo__img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-sunk);
}

.photo__caption {
  padding: 7px 9px 8px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}

.photo__pinned {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(29, 28, 26, .4);
}

.photo__del {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(29, 28, 26, .6);
  color: #fff;
  cursor: pointer;
}

.photo__del:hover { background: var(--danger); }
.photo__del svg { width: 13px; height: 13px; }

.photo__confirm {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 6px 5px 9px;
  border-radius: 99px;
  background: rgba(29, 28, 26, .88);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
}

.photo__confirm .confirm__btn { padding: 3px 8px; font-size: 11.5px; }

.photo-form {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
}

.photo-form__title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.filepick {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 14px;
  padding: 13px 15px;
  border: 1.5px dashed var(--hairline);
  border-radius: var(--radius-md);
  background: var(--surface-sunk);
  color: var(--ink-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s var(--ease), color .15s var(--ease);
}

.filepick:hover { border-color: var(--accent); color: var(--ink); }
.filepick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.filepick svg { width: 20px; height: 20px; flex: 0 0 auto; }
.filepick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.filepick.is-set {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.photo-form__loc {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
}

.photo-form__coords {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toast-host {
  position: fixed;
  z-index: 45;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 92px);

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;

  width: max-content;
  max-width: min(420px, calc(100vw - 28px));
  pointer-events: none;
}

.toast {
  padding: 10px 15px;
  border-radius: var(--radius-md);
  background: rgba(29, 28, 26, .93);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  box-shadow: var(--shadow-card);
  animation: toast-in .2s var(--ease);
}

.toast--error { background: var(--danger); }
.toast--gold  { background: linear-gradient(135deg, #f0ac1c, #d98a0a); font-weight: 650; }
.toast.is-leaving { animation: toast-out .2s var(--ease) forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(6px); } }

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  /* Spinners are status indicators, so keep them turning. */
  .fab__spinner,
  .boot__spinner,
  .btn.is-busy::after {
    animation: spin 1.2s linear infinite !important;
  }
}
