:root {
  --table: #c5d8e1;
  --sheet: #e7f0f4;
  --ink: #17303a;
  --muted: #4d6672;
  --coral: #e85d4c;
  --moss: #1f6a4a;
  --paper: #fffdf8;
  --tab-known: #f0d7a2;
  --tab-open: #d5e2c8;
  --line: #a9c0cb;
  --shadow: 0 10px 18px rgba(23, 48, 58, 0.14);
  --font: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--table);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

::selection {
  background: #b7d0db;
  color: var(--ink);
}

button, select, a, label, img, .stack-count {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

img { -webkit-user-drag: none; }

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

button, select, a.download, a.download-all, .packet-open, .person {
  cursor: pointer;
  touch-action: manipulation;
}

button {
  appearance: none;
  -webkit-appearance: none;
}

button:focus,
a:focus,
select:focus {
  outline: none;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.leaflet-container,
.leaflet-container:focus {
  outline: none;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px 28px;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 28px 0;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 22px;
  max-width: 100%;
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1;
}

#summary {
  margin: 6px 0 0;
  color: var(--muted);
}

.look {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.94);
}

.stage .look {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  box-shadow: 0 10px 28px rgba(16, 32, 39, 0.28);
}

.look button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 6px 14px;
  color: var(--muted);
  font-weight: 650;
}

.look button[aria-pressed="true"] {
  background: var(--ink);
  color: white;
}

.stage #look-note {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 68px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(440px, calc(100% - 140px));
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.94);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

#lightbox .look button {
  background: transparent;
  color: var(--muted);
}

#lightbox .look button[aria-pressed="true"] {
  background: var(--ink);
  color: white;
}

.views {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  max-width: 100%;
  min-width: 0;
  padding-bottom: 6px;
}

.views button {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 4px 0 6px;
  font-size: 1.15rem;
}

.views button:hover {
  color: var(--ink);
}

.views button[aria-current="page"] {
  border-bottom-color: var(--coral);
  font-weight: 650;
}

a.download-all:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

a.download-all {
  margin-left: 0;
  padding: 4px 0 6px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  color: var(--moss);
}

#view {
  padding: 20px 28px 56px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin: 0 0 20px;
}

.toolbar p {
  margin: 0;
}

.toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.toolbar select {
  field-sizing: content;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M1 1.4 6 6.2 11 1.4' fill='none' stroke='%2317303a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 36px 8px 16px;
}

.toolbar select:hover,
.toolbar select:focus,
.toolbar input[type="date"]:hover,
.toolbar input[type="date"]:focus {
  border-color: var(--ink);
}

.toolbar input[type="date"] {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: inherit;
  font: inherit;
}

#select-mode,
.share-go {
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 650;
}

#select-mode {
  background: var(--paper);
  border: 1px solid var(--line);
}

.share-go {
  background: var(--moss);
  color: white;
  border: 0;
}

.pick-mark {
  position: absolute;
  z-index: 1;
  left: 16px;
  bottom: 16px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid white;
  background: rgba(23, 48, 58, 0.45);
  box-shadow: 0 1px 4px rgba(23, 48, 58, 0.35);
}

.print.picked .pick-mark {
  background: var(--moss);
}

.print.picked .pick-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  width: 6px;
  height: 11px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.linkish,
a.download {
  background: none;
  border: 0;
  padding: 0;
  color: var(--moss);
  font-weight: 650;
  text-decoration: none;
}

.linkish:hover,
.packet a.download:hover,
.toolbar a.download:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.packet-open {
  display: block;
  width: 100%;
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
}

.packet a.download {
  display: inline-block;
  margin-top: auto;
  padding-top: 12px;
}

.year {
  margin: 28px 0 14px;
  font-size: 1.35rem;
  font-weight: 650;
}

.year:first-child { margin-top: 0; }

.packets {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 32px 16px;
  align-items: stretch;
  padding-top: 18px;
}

.packet {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  overflow: visible;
  margin-top: 0;
  padding: 14px;
  text-align: left;
  white-space: normal;
  background: var(--paper);
  border: 0;
  border-radius: 0 0 3px 3px;
  box-shadow: var(--shadow);
  transition: box-shadow 160ms ease;
}

.packet:hover {
  box-shadow: 0 14px 26px rgba(23, 48, 58, 0.18);
}

.packet::before {
  content: "";
  position: absolute;
  left: 0;
  top: -16px;
  width: 86px;
  height: 16px;
  background: var(--tab, var(--tab-known));
  border-radius: 8px 10px 0 0;
}

.packet.unplaced { --tab: var(--tab-open); }

.packet .print,
.grid .print {
  display: block;
  position: relative;
  min-width: 0;
  max-width: 100%;
  background: white;
  padding: 8px;
}

.play-mark {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(23, 48, 58, 0.82);
  pointer-events: none;
}

.play-mark::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 9px;
  border-style: solid;
  border-width: 7px 0 7px 11px;
  border-color: transparent transparent transparent white;
}

.packet img,
.grid img,
.map-pop img {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  object-fit: cover;
  background: #d5e1e6;
}

.packet img { aspect-ratio: 4 / 5; }

.stack-count {
  position: absolute;
  top: 16px;
  right: 16px;
  min-width: 1.6rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(23, 48, 58, 0.82);
  color: white;
  font-size: 0.82rem;
  font-weight: 650;
  text-align: center;
}

.packet .name {
  display: block;
  margin-top: 12px;
  font-size: 1.05rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.packet .meta,
.quiet {
  color: var(--muted);
}

.packet .meta {
  display: block;
  margin-top: 2px;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

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

.grid button.print {
  position: relative;
  min-width: 0;
  width: 100%;
  border: 0;
  padding: 8px;
  background: white;
  box-shadow: var(--shadow);
  text-align: left;
  white-space: normal;
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.grid button.print:hover {
  box-shadow: 0 14px 26px rgba(23, 48, 58, 0.18);
}

.grid button.print:active {
  transform: translateY(1px);
}

.grid button.print:focus-visible,
.packet-open:focus-visible,
.person:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--table), 0 0 0 5px var(--ink);
}

.grid img { aspect-ratio: 1; }

.more {
  margin-top: 22px;
  background: var(--ink);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}

.map-stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trail-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 14px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.trail-play {
  flex: none;
  min-width: 72px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-weight: 650;
}

.trail-play:hover { background: #102027; }

.trail-play:focus { outline: none; }

.trail-play:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.trail-readout {
  flex: 0 1 220px;
  min-width: 0;
}

.trail-readout .when {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.2;
}

.trail-readout .where {
  display: block;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trail-bar input[type="range"] {
  flex: 1 1 120px;
  min-width: 0;
  height: 32px;
  margin: 0;
  accent-color: var(--moss);
  cursor: pointer;
}

.trail-bar input[type="range"]:focus { outline: none; }

.trail-bar input[type="range"]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

#atlas {
  position: relative;
  z-index: 0;
  isolation: isolate;
  height: min(72vh, 760px);
  min-height: 420px;
  background: #e4dcc4;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 0 7px rgba(255, 253, 248, 0.72),
    0 18px 36px rgba(23, 48, 58, 0.16);
}

#atlas::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 450;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(42% 28% at 32% 18%, rgba(255, 253, 248, 0.42), transparent 72%),
    radial-gradient(120% 90% at 50% 46%, transparent 46%, rgba(23, 48, 58, 0.2) 100%);
  box-shadow: inset 0 0 70px rgba(23, 48, 58, 0.16);
}

.side {
  background: var(--sheet);
  border-radius: 18px;
  padding: 6px 8px 12px;
  max-height: min(72vh, 760px);
  overflow: auto;
  position: sticky;
  top: 16px;
}

.side h2 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 10px 8px 8px;
  background: var(--sheet);
  font-size: 1.02rem;
  font-weight: 650;
}

.side ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.side li + li { border-top: 1px solid var(--line); }

.side button {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 10px;
}

.side button .place-name { min-width: 0; }

.side button .count {
  flex: none;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.side button:hover {
  background: rgba(255, 253, 248, 0.85);
  color: var(--ink);
}

.side button.here {
  background: var(--paper);
  box-shadow: inset 3px 0 0 var(--moss);
}

.leaflet-marker-icon.photo-pin {
  background: var(--paper);
  border: 3px solid var(--paper) !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  box-shadow: 0 1px 0 rgba(255, 253, 248, 0.9), 0 8px 16px rgba(55, 42, 24, 0.32);
}

.leaflet-marker-icon.photo-pin:hover {
  box-shadow: 0 1px 0 rgba(255, 253, 248, 0.95), 0 12px 22px rgba(55, 42, 24, 0.4);
}

.leaflet-marker-icon.photo-pin img {
  width: 62px !important;
  height: 62px !important;
  max-width: 62px !important;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.leaflet-marker-icon.photo-pin.pin-sm img {
  width: 40px !important;
  height: 40px !important;
  max-width: 40px !important;
}

.leaflet-marker-icon.photo-pin.trail-now {
  box-shadow: 0 0 0 3px var(--moss), 0 8px 18px rgba(55, 42, 24, 0.35);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--paper);
  color: var(--ink);
}

.leaflet-popup-content-wrapper {
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 16px 34px rgba(55, 42, 24, 0.24);
}

.leaflet-popup-close-button {
  width: 32px !important;
  height: 32px !important;
  padding: 4px 0 0 !important;
  font: 600 22px/28px var(--font) !important;
  color: var(--muted) !important;
}

.leaflet-popup-close-button:hover {
  color: var(--ink) !important;
  background: transparent !important;
}

.leaflet-popup-content {
  margin: 0;
  line-height: 1.3;
}

.leaflet-popup-content .map-pop {
  width: min(300px, calc(100vw - 112px));
  padding: 14px 16px 16px;
}

.map-pop strong {
  display: block;
  margin: 0 28px 2px 0;
  font-size: 1.05rem;
}

.map-pop .count {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.map-pop .hero {
  width: 100%;
  aspect-ratio: 3 / 2;
  height: auto;
  border-radius: 10px;
  margin: 0 0 10px;
}

.map-pop .strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 10px;
}

.map-pop .strip img {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  border-radius: 8px;
}

.map-pop .nearby {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.map-pop .nearby-label {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.86rem;
}

.map-pop .nearby button {
  border: 0;
  border-radius: 999px;
  background: var(--sheet);
  color: var(--ink);
  padding: 6px 10px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
}

.map-pop .nearby button:hover {
  background: #d5e6ee;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.map-pop .map-actions .open-place,
.map-pop .map-actions a.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  line-height: 1.2;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.map-pop .map-actions .open-place {
  background: var(--sheet);
  color: var(--ink);
}

.map-pop .map-actions .open-place:hover {
  background: #d5e6ee;
}

.map-pop .map-actions a.download {
  background: var(--moss);
  color: white;
}

.map-pop .map-actions a.download:hover {
  background: #184e36;
  text-decoration: none;
}

.people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 20px 16px;
}

.person {
  display: block;
  width: 100%;
  padding: 0;
  background: none;
  border: 0;
  text-align: center;
}

.person img,
.person-face {
  display: block;
  object-fit: cover;
  border-radius: 50%;
  background: white;
}

.person img {
  width: 100%;
  aspect-ratio: 1;
  box-shadow: var(--shadow);
}

.person-face {
  width: 52px;
  height: 52px;
  flex: none;
}

.person:hover img {
  box-shadow: 0 0 0 3px var(--paper), 0 10px 18px rgba(23, 48, 58, 0.18);
}

.person .count {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.note {
  max-width: 68ch;
  margin: 0 0 16px;
}

#lightbox:not([open]) { display: none; }

#lightbox[open] {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(1180px, 96vw);
  height: min(920px, 94vh);
  max-height: 94vh;
  padding: 16px;
  border: 0;
  border-radius: 12px;
  background: #102027;
  color: white;
}

#lightbox::backdrop { background: rgba(16, 32, 39, 0.78); }

.lightbox-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  position: relative;
  z-index: 3;
}

.lightbox-bar p {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.lightbox-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

#lightbox button {
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 650;
}

#lightbox button:hover {
  background: white;
}

#lightbox button:disabled,
#lightbox button:disabled:hover {
  opacity: 0.35;
  cursor: default;
  background: var(--paper);
}

.edge:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
}

#lightbox button[hidden] { display: none; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: black;
  touch-action: none;
}

.photo-frame {
  position: absolute;
  inset: 0;
}

#photo-full,
#photo-edit,
#photo-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: black;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}

.look[hidden],
#look-note[hidden],
#photo-save[hidden],
#photo-full[hidden],
#photo-edit[hidden],
#photo-video[hidden],
#edit-tray[hidden],
#crop-layer[hidden],
#crop-bar[hidden],
#edit-tools[hidden],
.edit-panel[hidden],
.edit-frame-note[hidden],
#photo-hint[hidden] {
  display: none;
}

#lightbox #photo-save:not([hidden]) {
  display: inline-flex;
  align-items: center;
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.stage.can-drag #photo-full,
.stage.can-drag #photo-edit { cursor: grab; }
.stage.dragging #photo-full,
.stage.dragging #photo-edit { cursor: grabbing; }
.stage.can-zoom #photo-full,
.stage.can-zoom #photo-edit { cursor: zoom-in; }
.stage.is-cropping .edge { visibility: hidden; pointer-events: none; }

#look-edit.has-edit::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--moss);
  vertical-align: 1px;
}

#edit-tray {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  width: min(520px, calc(100% - 24px));
  max-height: min(50%, 420px);
  overflow: auto;
  padding: 8px 10px 10px;
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.98);
  color: var(--ink);
  box-shadow: 0 16px 40px rgba(8, 16, 20, 0.35);
  transform: translateX(-50%);
  touch-action: auto;
}

#edit-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.edit-panels {
  touch-action: pan-y;
}

.edit-dock {
  display: flex;
  flex-direction: column;
  flex: none;
  gap: 8px;
}

.edit-looks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.edit-looks[hidden] { display: none; }

.edit-rail {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  touch-action: pan-x;
}

.edit-rail::-webkit-scrollbar { display: none; }

.edit-sliders {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
}

.edit-slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}

.edit-slider-head label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
}

.edit-sliders input[type="range"] {
  width: 100%;
  height: 36px;
  margin: 0;
  accent-color: var(--ink);
}

.edit-frame-note {
  margin: 2px 2px 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

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

#crop-bar p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

#lightbox #edit-tray button {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

#lightbox #edit-tray .edit-looks button {
  min-height: 44px;
  padding: 8px 12px;
}

#lightbox #edit-tray .edit-rail button {
  flex: 1 0 auto;
  padding: 8px 10px;
  font-size: 0.92rem;
  white-space: nowrap;
}

#lightbox #edit-tray button[aria-pressed="true"] {
  background: var(--ink);
  color: white;
}

#lightbox #edit-tray .edit-readout {
  min-width: 52px;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

#lightbox #edit-tray .edit-readout.is-set {
  color: var(--moss);
}

#lightbox #edit-tray .edit-rail button.has-edit::after,
#lightbox #edit-tray #edit-crop.has-edit::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--moss);
  vertical-align: 1px;
}

#lightbox #edit-tray .edit-actions button {
  flex: 1 1 auto;
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

#lightbox #edit-tray .edit-actions button:hover {
  background: white;
}

#lightbox #edit-tray .edit-actions button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

#lightbox #edit-tray .edit-actions #edit-compare {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  line-height: 1.05;
  border-color: var(--moss);
  color: var(--moss);
}

#lightbox #edit-tray .edit-actions #edit-compare small {
  display: block;
  font-size: 0.68rem;
  font-weight: 650;
  line-height: 1.1;
  opacity: 0.8;
}

#lightbox #edit-tray .edit-actions #edit-compare[aria-pressed="true"],
#lightbox #edit-tray .edit-actions #edit-compare[aria-pressed="true"]:hover {
  border-color: var(--moss);
  background: var(--moss);
  color: white;
}

#lightbox #edit-tray .edit-actions #edit-done,
#lightbox #edit-tray .edit-actions #edit-done:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

#edit-status {
  margin: 8px 0 0;
  color: var(--moss);
  font-size: 0.82rem;
}

#edit-status[hidden],
#compare-tag[hidden] {
  display: none;
}

#compare-tag {
  position: absolute;
  z-index: 8;
  top: 16px;
  left: 50%;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 650;
  transform: translateX(-50%);
}

#crop-layer {
  position: absolute;
  z-index: 6;
  touch-action: none;
}

#crop-window {
  position: absolute;
  cursor: move;
  outline: 2px solid white;
  box-shadow: 0 0 0 9999px rgba(8, 16, 20, 0.55);
  background:
    linear-gradient(to right, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.75) calc(33.33% - 0.5px), rgba(255, 255, 255, 0.75) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px)),
    linear-gradient(to right, transparent calc(66.66% - 0.5px), rgba(255, 255, 255, 0.75) calc(66.66% - 0.5px), rgba(255, 255, 255, 0.75) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)),
    linear-gradient(to bottom, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.75) calc(33.33% - 0.5px), rgba(255, 255, 255, 0.75) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px)),
    linear-gradient(to bottom, transparent calc(66.66% - 0.5px), rgba(255, 255, 255, 0.75) calc(66.66% - 0.5px), rgba(255, 255, 255, 0.75) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px));
}

#crop-window span {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

#crop-window span[data-handle="nw"] { left: 6px; top: 6px; cursor: nwse-resize; }
#crop-window span[data-handle="n"] { left: 50%; top: 6px; transform: translateX(-50%); cursor: ns-resize; }
#crop-window span[data-handle="ne"] { right: 6px; top: 6px; cursor: nesw-resize; }
#crop-window span[data-handle="e"] { right: 6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
#crop-window span[data-handle="se"] { right: 6px; bottom: 6px; cursor: nwse-resize; }
#crop-window span[data-handle="s"] { left: 50%; bottom: 6px; transform: translateX(-50%); cursor: ns-resize; }
#crop-window span[data-handle="sw"] { left: 6px; bottom: 6px; cursor: nesw-resize; }
#crop-window span[data-handle="w"] { left: 6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.edge {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  padding: 0;
  font-size: 2.6rem;
  line-height: 1;
  color: white !important;
  background: linear-gradient(90deg, rgba(16, 32, 39, 0.5), transparent) !important;
  border-radius: 0 !important;
}

.edge.next {
  right: 0;
  background: linear-gradient(270deg, rgba(16, 32, 39, 0.45), transparent) !important;
}

.edge:disabled { opacity: 0; }

.hint {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
  text-align: center;
}

.leaflet-top.leaflet-left {
  top: auto;
  bottom: 7%;
  left: 50%;
  transform: translateX(-50%);
}

.leaflet-top.leaflet-left .leaflet-control-zoom,
.leaflet-top.leaflet-left .map-home {
  margin-top: 0;
  margin-left: 0;
  border: 0 !important;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(55, 42, 24, 0.18);
}

.leaflet-top.leaflet-left .leaflet-control {
  float: left;
  clear: both;
}

.leaflet-top.leaflet-left .map-home {
  margin-top: 8px;
}

.map-home button {
  display: block;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 650;
  font-size: 0.78rem;
}

.map-home button:hover { background: white; }

.map-home button:focus { outline: none; }

.map-home button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.leaflet-control-zoom a {
  width: 40px !important;
  height: 40px !important;
  line-height: 40px !important;
  font-size: 20px !important;
  color: var(--ink) !important;
  background: var(--paper) !important;
  border-bottom: 1px solid var(--line) !important;
}

.leaflet-control-zoom a:last-child {
  border-bottom: 0 !important;
}

.leaflet-control-zoom a:hover {
  background: white !important;
  color: var(--ink) !important;
}

.leaflet-control-zoom a:focus {
  outline: none;
}

.leaflet-control-zoom a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.leaflet-popup-close-button {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.empty {
  max-width: 46ch;
  background: var(--sheet);
  border-radius: 18px;
  padding: 22px;
}

#install[hidden] { display: none; }

#install:not([hidden]) {
  position: fixed;
  z-index: 40;
  left: max(12px, env(safe-area-inset-left, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.96);
  color: var(--ink);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

#install-copy {
  flex: 1 1 180px;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.35;
}

.install-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#install-go {
  min-height: 40px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-weight: 650;
}

#install-go[hidden] { display: none; }

#install-later {
  min-height: 40px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}

@media (max-width: 800px) {
  body { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  .top {
    align-items: stretch;
    gap: 10px;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 0;
  }
  #view { padding: 12px 16px 28px; }
  h1 { font-size: 2rem; }
  .head-actions { justify-content: flex-start; gap: 4px 16px; }
  a.download-all,
  .toolbar .linkish,
  .toolbar a.download {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  .look button,
  #select-mode,
  .share-go,
  .toolbar select,
  .toolbar input[type="date"] {
    min-height: 44px;
  }
  .toolbar label { max-width: 100%; }
  .toolbar select { max-width: 100%; }
  .views {
    position: fixed;
    left: max(12px, env(safe-area-inset-left, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    width: auto;
    padding: 6px;
    background: rgba(255, 253, 248, 0.94);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
  .views button {
    min-height: 44px;
    border-bottom: 0;
    border-radius: 14px;
    padding: 8px 2px;
    font-size: clamp(0.8rem, 2.8vw, 1rem);
    white-space: nowrap;
  }
  .views button[aria-current="page"] {
    background: var(--ink);
    color: white;
    border-bottom-color: transparent;
  }
  .packets, .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .people { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .map-layout {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    min-width: 0;
  }
  #atlas {
    width: min(78%, 340px);
    height: auto;
    aspect-ratio: 1;
    min-height: 0;
    max-height: none;
    margin-inline: auto;
  }
  .trail-bar {
    flex-wrap: nowrap;
    gap: 8px;
    border-radius: 999px;
    padding: 6px 10px 6px 6px;
  }
  .trail-play {
    min-width: 64px;
    min-height: 40px;
    padding: 0 12px;
  }
  .trail-readout { flex: 1 1 auto; }
  .trail-readout .when,
  .trail-readout .where {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .trail-bar input[type="range"] {
    flex: 1 1 72px;
    height: 32px;
  }
  .leaflet-top.leaflet-left {
    top: 16px;
    bottom: auto;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .leaflet-top.leaflet-left .leaflet-control {
    float: none;
    clear: none;
  }
  .leaflet-top.leaflet-left .map-home { margin-top: 0; }
  .side {
    position: static;
    max-height: none;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    padding: 12px 12px 4px;
  }
  .side h2 {
    position: static;
    padding: 2px 2px 8px;
  }
  .side ul {
    display: flex;
    gap: 8px;
    max-width: 100%;
    overflow-x: auto;
    padding: 0 0 8px;
  }
  .side li + li { border-top: 0; }
  .side button {
    width: auto;
    flex: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper);
    padding: 8px 14px;
    white-space: nowrap;
  }
  .side button.here {
    box-shadow: none;
    border-color: var(--moss);
    background: #e5f2eb;
  }
  .packet a.download {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 8px;
    padding-top: 0;
  }
  .leaflet-control-zoom a,
  .map-home button {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
  }
  .lightbox-bar { flex-wrap: wrap; }
  .lightbox-tools {
    width: 100%;
    gap: 4px;
  }
  #lightbox[open] {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    padding:
      calc(10px + env(safe-area-inset-top, 0px))
      max(10px, env(safe-area-inset-right, 0px))
      calc(10px + env(safe-area-inset-bottom, 0px))
      max(10px, env(safe-area-inset-left, 0px));
  }
  #lightbox .lightbox-tools button,
  #lightbox #photo-save:not([hidden]) {
    min-height: 40px;
    padding: 6px 8px;
    font-size: 0.9rem;
  }
  #lightbox #zoom-in,
  #lightbox #zoom-out,
  #lightbox #zoom-fit {
    min-width: 40px;
    justify-content: center;
  }
  #edit-tray {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: min(48vh, 360px);
    transform: none;
  }
  #lightbox #edit-tray .edit-rail button {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 4px;
    font-size: 0.82rem;
  }
  #lightbox #edit-tray .edit-panel .edit-actions button {
    flex: 1 1 calc(50% - 8px);
  }
  #crop-window span { width: 28px; height: 28px; }
  .edge { width: 56px; }
  .hint { font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
