:root {
  --bg: #faf6ef; --card: #fff; --ink: #2b2a28; --muted: #77716a; --line: #e8e0d3;
  --accent: #c4552d; --accent-dark: #a24322; --sea: #2f5d62;
  --radius: 14px; --shadow: 0 2px 14px rgba(60, 40, 20, .08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1a18; --card: #262421; --ink: #f1ece4; --muted: #a39b90; --line: #3a3732; --accent: #e07a52; --accent-dark: #ee9068; --sea: #7fb0b4; --shadow: 0 2px 14px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* so styled buttons still disappear when hidden */
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 Inter, system-ui, sans-serif; }
h1, h2, h3 { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; line-height: 1.2; margin: 0 0 .4em; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 1000; }
.brand { font: 400 1.35rem 'DM Serif Display', serif; color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: 18px; align-items: center; }
.top nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 36px 16px; }
.linklike { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 28px 24px 40px; }
.hero { text-align: center; padding: 34px 0 20px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.hero p { color: var(--muted); font-size: 1.1rem; margin: 0 auto; max-width: 560px; }
.stats { display: flex; justify-content: center; gap: 34px; margin-top: 20px; flex-wrap: wrap; }
.stats b { display: block; font: 400 1.8rem 'DM Serif Display', serif; color: var(--sea); }
.stats span { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }

.stats > div { position: relative; }
.hasTip { cursor: help; outline: none; }
.hasTip > span { border-bottom: 1px dotted var(--muted); }
.tip { display: none; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin: 8px 0 0; padding: 10px 16px; list-style: none; text-align: left; min-width: 150px; max-height: 280px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); font-size: .9rem; line-height: 1.7; z-index: 1100; white-space: nowrap; }
.hasTip:hover .tip, .hasTip:focus .tip, .hasTip:focus-within .tip { display: block; }
.reset-btn { display: grid !important; place-items: center; }
.map { height: clamp(380px, 56vh, 480px); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); z-index: 1; }
.map.small { height: 320px; }
.pin { width: 15px; height: 15px; background: #c4552d; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.numpin { width: 28px; height: 28px; background: var(--accent); color: #fff; border: 2px solid #fff; border-radius: 50%; display: grid; place-items: center; font: 600 .8rem Inter, sans-serif; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.leaflet-popup-content { font-family: Inter, sans-serif; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 38px 0 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 1.7rem; }

.year { position: relative; padding: 6px 0 10px 22px; margin-bottom: 18px; }
.year::before { content: ''; position: absolute; left: 0; top: 17px; width: 8px; height: 8px; border-radius: 50%; background: var(--yc, var(--accent)); }
.legend { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.legend button { display: flex; align-items: center; gap: 8px; border: 0; background: none; border-radius: 6px; padding: 3px 8px; font-size: .8rem; text-align: left; }
.legend button:hover { background: var(--bg); }
.legend .editkey { color: var(--muted); font-size: .72rem; border-top: 1px solid var(--line); border-radius: 0; margin-top: 3px; padding-top: 5px; }
.keyrow { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.modal .keyrow input[type=text] { margin-top: 0; flex: 1; }
.modal .keyrow input[type=color] { width: 44px; height: 38px; padding: 2px; margin-top: 0; flex: none; cursor: pointer; }
.legend button.off { opacity: .4; text-decoration: line-through; }
.legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.year-h { font: 400 2rem 'DM Serif Display', serif; margin: 0; }
.year-n { color: var(--accent); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 14px; }
.tiles { display: flex; flex-wrap: wrap; gap: 14px; }
.tile { width: 118px; text-decoration: none; color: inherit; }
.timg { aspect-ratio: 1 / 1.1; border-radius: 6px; background: linear-gradient(135deg, var(--sea), var(--accent)) center/cover; box-shadow: var(--shadow); transition: transform .15s; }
.tile:hover .timg { transform: translateY(-3px); }
.tt { font: 400 .95rem 'DM Serif Display', serif; margin-top: 7px; line-height: 1.25; }
.ts { color: var(--muted); font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; margin-top: 3px; line-height: 1.4; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); text-decoration: none; color: inherit; display: block; transition: transform .15s; }
.card:hover { transform: translateY(-3px); }
.card .img { aspect-ratio: 4/3; background: linear-gradient(135deg, var(--sea), var(--accent)); background-size: cover; background-position: center; }
.card .body { padding: 14px 18px 18px; }
.card h3 { font-size: 1.25rem; margin-bottom: 2px; }
.meta { color: var(--muted); font-size: .88rem; }
.card p { margin: 8px 0 0; color: var(--ink); font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.banner { height: 340px; background: linear-gradient(135deg, var(--sea), var(--accent)) center/cover; display: flex; align-items: flex-end; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 12px 36px; flex-wrap: wrap; margin: 4px 0 26px; }
.split-text { flex: 1 1 280px; min-width: 0; }
.split-text h1 { font-size: clamp(2rem, 4.6vw, 3.2rem); margin: 0 0 6px; }
.split-text .meta { font-size: 1rem; }
.split-text .summary { margin: 14px 0 0; font-size: 1.05rem; line-height: 1.65; max-width: 52ch; }
.split-img { flex: 0 1 auto; min-width: 0; padding: 0; border: 0; background: none; border-radius: 12px; cursor: zoom-in; line-height: 0; box-shadow: var(--shadow); overflow: hidden; }
.split-img img { width: auto; height: auto; max-width: min(540px, 100%); max-height: 420px; border-radius: 12px; }
@media (max-width: 700px) { .split-img { flex-basis: 100%; } .split-img img { max-width: 100%; margin: 0 auto; } }
.banner.short { height: 260px; }
.banner .shade { width: 100%; padding: 60px 24px 26px; background: linear-gradient(transparent, rgba(0,0,0,.65)); color: #fff; }
.banner .inner { max-width: 1060px; margin: 0 auto; }
.banner h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0; }
.banner .meta { color: rgba(255,255,255,.85); }
.summary { white-space: pre-wrap; font-size: 1.08rem; max-width: 760px; margin: 0 0 8px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }

.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; transition: transform .15s; }
.pcard:hover { transform: translateY(-3px); }
.pimg { position: relative; aspect-ratio: 16/10; background: linear-gradient(135deg, var(--sea), var(--accent)) center/cover; }
.pimg .num { position: absolute; top: 10px; left: 10px; width: 30px; height: 30px; font-size: .85rem; border: 2px solid #fff; }
.pbody { padding: 12px 16px 16px; }
.pbody h3 { font-size: 1.15rem; margin: 0 0 2px; }
.pbody p { margin: 8px 0 0; font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.narrow { max-width: 800px; }
.back { text-decoration: none; font-weight: 500; }
.place-title { font-size: clamp(2rem, 6vw, 3rem); margin: 4px 0 8px; }
.story { white-space: pre-wrap; font-size: 1.1rem; line-height: 1.75; margin: 18px 0 26px; }
/* place page: notes + even photo grid */
.notes-box { margin: 6px 0 26px; }
.place-notes { white-space: pre-wrap; max-width: 760px; font-size: 1.05rem; line-height: 1.7; margin-bottom: 10px; }
.notes-box textarea { display: block; width: 100%; max-width: 760px; min-height: 220px; padding: 12px 14px; font: inherit; line-height: 1.65; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; resize: vertical; }
.notes-box .toolbar { margin: 8px 0 0; }
.cap { margin-top: 6px; font-size: .8rem; line-height: 1.4; color: var(--muted); letter-spacing: .01em; min-height: 1.1em; }
.cap.ed { cursor: text; border-radius: 4px; }
.cap.ed:hover { background: rgba(128,128,128,.1); }
.cap .ph { opacity: .55; font-style: italic; }
.cap input { width: 100%; font: inherit; padding: 3px 6px; background: var(--card); color: var(--ink); border: 1px solid var(--accent); border-radius: 4px; }
.photos.big { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.photos.big button { aspect-ratio: 4/3; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; font-weight: 500; }
.pager a { text-decoration: none; }

.place { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); scroll-margin-top: 80px; }
.place-head { display: flex; gap: 14px; align-items: flex-start; }
.num { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; }
.place h3 { margin: 0; font-size: 1.35rem; }
.place .notes { white-space: pre-wrap; margin: 12px 0 0; }
.place .actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 14px; }
.photos button { padding: 0; border: 0; background: var(--line); border-radius: 10px; overflow: hidden; aspect-ratio: 1; cursor: zoom-in; }
.photos img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.photos button:hover img { transform: scale(1.05); }

button, .btn { font: 500 .9rem Inter, sans-serif; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 999px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-dark); }
button.danger { color: #c0392b; }
button.small { padding: 4px 11px; font-size: .8rem; }
button:disabled { opacity: .6; cursor: wait; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; border: 2px dashed var(--line); border-radius: var(--radius); }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 2000; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; }
.modal { background: var(--card); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 560px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.modal h2 { font-size: 1.5rem; }
.modal label { display: block; font-weight: 500; font-size: .88rem; margin: 12px 0; }
.modal select { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; }
.modal input, .modal textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; }
.modal textarea { min-height: 130px; resize: vertical; }
.modal .row { display: flex; gap: 8px; }
.modal .row input { margin-top: 0; }
.cover-actions { margin-top: 14px; }
#coverPool { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); max-height: 220px; overflow-y: auto; }
.crop-label { font-weight: 500; font-size: .88rem; margin: 14px 0 6px; }
.crop-frame { background-size: cover; background-position: 50% 50%; border-radius: 10px; border: 1px solid var(--line); cursor: grab; touch-action: none; user-select: none; box-shadow: var(--shadow); }
.crop-frame.drag { cursor: grabbing; }
.crop-frame[data-k=tile] { width: 150px; aspect-ratio: 1 / 1.1; }
.crop-frame[data-k=banner] { width: 100%; aspect-ratio: 3.1 / 1; }
.modal .flatpickr-wrapper { display: block; width: 100%; }
.modal label .flatpickr-calendar { font-weight: 400; margin-top: 4px; }
.datepick { margin: 12px 0; }
.datepick .lbl { font-weight: 500; font-size: .88rem; margin-bottom: 6px; }
.datepick .hint { font-weight: 400; }
.modal input#range { display: none; }
.datepick .small { margin-top: 8px; }
.flatpickr-calendar.inline { width: 100% !important; max-width: 320px; box-shadow: var(--shadow); border: 1px solid var(--line); margin: 0 auto; }
.modal .flatpickr-calendar select { display: inline-block; width: auto; margin: 0; padding: 0 .5ch; border: 0; background: transparent; border-radius: 0; color: #393939; }
.modal .flatpickr-calendar input { display: inline-block; margin: 0; padding: 0 0 0 .5ch; border: 0; background: transparent; border-radius: 0; }
.modal .flatpickr-calendar .numInputWrapper { width: 7ch; }
.modal .flatpickr-calendar .numInputWrapper input { width: 100%; color: #393939; }
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange { background: var(--accent); border-color: var(--accent); }
.flatpickr-day.inRange { background: rgba(196, 85, 45, .15); border-color: transparent; box-shadow: -5px 0 0 rgba(196, 85, 45, .15), 5px 0 0 rgba(196, 85, 45, .15); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.hint { color: var(--muted); font-size: .82rem; margin: 6px 0 0; }
.error { color: #c0392b; font-size: .88rem; min-height: 1.2em; margin: 8px 0 0; }
.results { margin: 8px 0; }
.results button { display: block; width: 100%; text-align: left; border-radius: 8px; margin-bottom: 4px; font-size: .85rem; }
.pickmap { height: 240px; border-radius: 10px; border: 1px solid var(--line); margin-top: 8px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(10,10,10,.94); z-index: 3000; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; color: #fff; }
.lightbox img { max-height: 76vh; max-width: 94vw; object-fit: contain; border-radius: 6px; }
.lightbox video { max-height: 76vh; max-width: 94vw; border-radius: 6px; background: #000; }
.ptile.isvid .tpic::after { content: '▶'; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46px; height: 46px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; padding-left: 3px; font-size: 1.1rem; pointer-events: none; }
.lightbox .cap { margin-top: 12px; min-height: 1.5em; text-align: center; max-width: 700px; }
.lightbox .lbtools { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.lightbox button { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 1.6rem; padding: 10px 16px; }
.lightbox .prev { left: 12px; } .lightbox .next { right: 12px; }
.lightbox .x { position: absolute; top: 14px; right: 14px; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 90px); background: #2b2a28; color: #fff; padding: 11px 20px; border-radius: 999px; z-index: 5000; transition: transform .25s; max-width: 90vw; }
#toast.show { transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .top { padding: 12px 16px; } .wrap { padding: 20px 16px 30px; }
  .banner { height: 260px; } .map { height: 360px; } .map.small { height: 300px; }
  .place-head { flex-wrap: wrap; } .place .actions { margin-left: 48px; justify-content: flex-start; }
  .two { grid-template-columns: 1fr; }
}

/* trip form: where you went */
.dests { margin: 12px 0; }
.dests .lbl { font-weight: 500; font-size: .88rem; margin-bottom: 6px; }
.dests .hint { font-weight: 400; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px 3px 12px; font-size: .88rem; }
.chip button { border: 0; background: none; padding: 2px 7px; border-radius: 999px; font-size: .75rem; color: var(--muted); }
.chip button:hover { color: #c0392b; }

.popedit { font-size: .8rem; margin-left: 4px; white-space: nowrap; }

/* trip thumbnails on the home page: a little pencil in edit mode */
.tilewrap { position: relative; width: 118px; }
.tile-edit { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); color: #333; font-size: .9rem; line-height: 1; box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: pointer; }
.tile-edit:hover { background: #fff; color: var(--accent); }

/* place photos: a grid you can rearrange (drag to move, corner to resize, scissors to crop) */
.psec { margin: 4px 0 28px; }
.psec-title { font: 400 1.5rem 'DM Serif Display', serif; margin: 22px 0 6px; }
.psec-text { white-space: pre-wrap; max-width: 760px; line-height: 1.65; margin: 0 0 12px; }
.grid-hint { margin: 2px 0 12px; }
.pgrid-wrap { container-type: inline-size; }
.pgrid { --cols: 4; --gap: 14px; --capH: 36px; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--gap); grid-auto-flow: row dense;
  grid-auto-rows: calc((100cqw - (var(--cols) - 1) * var(--gap)) / var(--cols) * 0.8 + var(--capH)); }
@media (max-width: 900px) { .pgrid { --cols: 3; } }
@media (max-width: 520px) { .pgrid { --cols: 2; --gap: 10px; } .ptile.w3 { grid-column: span 2; } }
.ptile { margin: 0; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ptile.w1 { grid-column: span 1; } .ptile.w2 { grid-column: span 2; } .ptile.w3 { grid-column: span 3; }
.ptile.h1 { grid-row: span 1; } .ptile.h2 { grid-row: span 2; } .ptile.h3 { grid-row: span 3; }
.tpic { flex: 1; min-height: 0; border-radius: 4px; cursor: zoom-in; }
.ptile .cap { flex: none; height: var(--capH); margin-top: 4px; overflow: hidden; min-height: 0; overflow-wrap: anywhere; } /* --capH is set per grid from the longest caption (fitCaps in app.js) */
.ptile .cap input { width: 100%; }
.tcrop { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); color: #333; box-shadow: 0 1px 4px rgba(0,0,0,.35); font-size: .9rem; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; }
.rz { position: absolute; right: 3px; bottom: calc(var(--capH) + 7px); width: 26px; height: 26px; cursor: nwse-resize; touch-action: none; opacity: 0; transition: opacity .15s;
  background: linear-gradient(135deg, transparent 0 52%, #fff 52% 62%, transparent 62% 74%, #fff 74% 84%, transparent 84%); filter: drop-shadow(0 0 2px rgba(0,0,0,.7)); }
.ptile:hover .tcrop, .ptile:hover .rz, .ptile:focus-within .tcrop, .ptile.resizing .rz { opacity: 1; }
@media (hover: none) { .tcrop, .rz { opacity: 1; } }
.ptile.resizing .tpic { outline: 2px solid var(--accent); }
.drag-ghost { opacity: .35; }
.crop-frame.tilecrop { margin: 8px 0; }

/* visitors: no empty caption strip when none of the photos in a grid has a caption */
.pgrid.nocap { --capH: 0px; }
.pgrid.nocap .cap { display: none; }

/* edge handles: drag the right edge for width, the bottom edge for height */
.rz-edge { position: absolute; touch-action: none; opacity: 0; transition: opacity .15s; z-index: 2; }
.rz-edge::after { content: ''; position: absolute; background: #fff; border-radius: 3px; box-shadow: 0 0 3px rgba(0,0,0,.65); }
.rz-r { right: -2px; top: 18%; bottom: calc(var(--capH) + 4px + 18%); width: 18px; cursor: ew-resize; }
.rz-r::after { right: 5px; top: 50%; width: 4px; height: 36px; transform: translateY(-50%); }
.rz-b { bottom: calc(var(--capH) + 4px - 8px); left: 18%; right: 18%; height: 18px; cursor: ns-resize; }
.rz-b::after { bottom: 6px; left: 50%; height: 4px; width: 36px; transform: translateX(-50%); }
.ptile:hover .rz-edge, .ptile.resizing .rz-edge { opacity: 1; }
@media (hover: none) { .rz-edge { opacity: 1; } }

/* sections (edit mode) */
.psec-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px 16px; flex-wrap: wrap; margin: 20px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.psec:first-of-type .psec-head { border-top: 0; padding-top: 0; margin-top: 6px; }
.psec-head .psec-title { margin: 0 0 4px; }
.psec-untitled { color: var(--muted); font-style: italic; }
.psec-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.pgrid.empty { display: flex; align-items: center; justify-content: center; min-height: 100px; border: 2px dashed var(--line); border-radius: 8px; }
.pgrid.empty::before { content: 'Drag photos here, or use the ⇄ button on a photo'; color: var(--muted); font-size: .85rem; }
.tmove { position: absolute; top: 6px; left: 6px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); color: #333; box-shadow: 0 1px 4px rgba(0,0,0,.35); font-size: .95rem; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; z-index: 2; }
.ptile:hover .tmove, .ptile:focus-within .tmove { opacity: 1; }
@media (hover: none) { .tmove { opacity: 1; } }
.movelist { display: grid; gap: 6px; margin: 10px 0; }
.movelist button { text-align: left; border-radius: 8px; }

/* greyed-out buttons (like "move section down" on the last section) do nothing and show a normal cursor;
   the busy cursor stays only for buttons that are actually working (e.g. "Uploading…") */
.psec-tools button:disabled, .movelist button:disabled { cursor: default; }
.psec-tools button:disabled:hover, .movelist button:disabled:hover { border-color: var(--line); }

/* the page shown before the site password is entered */
.lockwrap { display: grid; place-items: center; min-height: 60vh; }
.lockcard { text-align: center; max-width: 380px; width: 100%; padding: 8px 0; }
.lockcard h1 { font-size: clamp(2rem, 6vw, 2.6rem); }
.lockcard p { color: var(--muted); margin: 0 0 18px; }
.lockcard form { display: grid; gap: 10px; }
.lockcard input { padding: 11px 14px; font: inherit; text-align: center; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; }
.lockcard .error { min-height: 1.2em; }

/* ---------- the front page and the extra sections ---------- */
#navLinks { display: contents; }
.acards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 22px; margin-top: 10px; }
.acard { display: block; text-decoration: none; color: inherit; }
.acard-img { aspect-ratio: 4 / 3; border-radius: 10px; background: linear-gradient(135deg, var(--sea), var(--accent)) center/cover; box-shadow: var(--shadow); transition: transform .15s; }
.acard:hover .acard-img { transform: translateY(-3px); }
.acard-t { font: 400 1.35rem 'DM Serif Display', serif; margin-top: 10px; line-height: 1.25; }
.acard-n { color: var(--muted); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; margin-top: 2px; }
.area-title { font-size: clamp(1.8rem, 4.4vw, 2.8rem); margin: 0; }
.ecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
.ecardwrap { position: relative; }
.ecard { display: block; text-decoration: none; color: inherit; }
.ecard-img { aspect-ratio: 1 / 1.1; border-radius: 6px; background: linear-gradient(135deg, var(--sea), var(--accent)) center/cover; box-shadow: var(--shadow); transition: transform .15s; }
.ecard:hover .ecard-img { transform: translateY(-3px); }
.ecard-s { color: var(--muted); font-size: .85rem; line-height: 1.4; margin-top: 2px; }
.eblock.long { padding: 34px 0 10px; border-top: 1px solid var(--line); margin-top: 18px; }
.eblock.long:first-of-type { border-top: 0; margin-top: 0; }
.e-title { font-size: clamp(1.5rem, 3.4vw, 2.2rem); margin: 0 0 6px; }
.e-summary { margin: 0 0 12px; font-size: 1.05rem; line-height: 1.6; max-width: 62ch; color: var(--muted); }
.addsec { display: grid; gap: 8px; margin-top: 8px; }
.arow { display: flex; align-items: center; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.arow .aname { flex: 1 1 160px; min-width: 0; }
.arow .atype { flex: 1 1 100%; order: 5; margin: -2px 0 2px; font-size: .78rem; }
.small-spacer { display: inline-block; width: 34px; }
.eblock button:disabled { cursor: default; }
.arow .alabel { width: 8.5em; padding: 2px 6px; font-size: .85rem; }
.psec.sub { margin-left: 20px; padding-left: 16px; border-left: 3px solid var(--line); }
.psec.sub .psec-title { font-size: 1.2rem; }
.psec.sub .psec-head { border-top: 0; padding-top: 0; margin-top: 6px; }
.psec.textonly { margin-bottom: 18px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; margin: 10px 0; }
label.check input { width: auto; margin-top: 4px; }
.movelist .hint { margin-left: 6px; }

/* small text boxes that sit in a photo grid */
.ttext-body { flex: 1; min-height: 0; overflow: auto; background: transparent; border-radius: 4px; padding: 4px 2px; white-space: pre-wrap; line-height: 1.55; font-size: .95rem; }
.tedit, .tdel { position: absolute; top: 6px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); color: #333; box-shadow: 0 1px 4px rgba(0,0,0,.35); font-size: .9rem; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; z-index: 3; }
.tedit { right: 38px; } .tdel { right: 6px; }
.tdel:hover { color: #b3261e; }
.ptile:hover .tedit, .ptile:hover .tdel, .ptile:focus-within .tedit, .ptile:focus-within .tdel { opacity: 1; }
@media (hover: none) { .tedit, .tdel { opacity: 1; } }
.ttext .rz { bottom: 7px; }
.ttext .rz-r { bottom: calc(4px + 18%); }
.ttext .rz-b { bottom: -4px; }
/* no border at all; the edit buttons and resize handles still show when you point at a box */
.fmtbar { display: flex; align-items: center; gap: 6px; margin: 8px 0 4px; }
.fmtbar button { min-width: 34px; padding: 3px 8px; font-size: .95rem; }
.fmtbar .hint { margin-left: 4px; }

/* selecting several photos */
.selbar { position: sticky; top: 62px; z-index: 20; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin: 6px 0 12px; background: var(--card); border: 1px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow); }
.selbar .selcount { font-weight: 600; margin-right: auto; }
.gal.selecting .ptile { cursor: pointer; }
.gal.selecting .tpic { cursor: pointer; }
.gal.selecting .tmove, .gal.selecting .tcrop, .gal.selecting .tedit, .gal.selecting .tdel, .gal.selecting .rz, .gal.selecting .rz-edge { display: none; }
.gal.selecting .ptile::after { content: ''; position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.9); border: 2px solid var(--accent); z-index: 4; pointer-events: none; }
.gal.selecting .ptile.picked::after { content: '✓'; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.gal.selecting .ptile.picked .tpic, .gal.selecting .ptile.picked .ttext-body { outline: 3px solid var(--accent); outline-offset: -3px; }
.movehead { font-size: 1rem; margin: 14px 0 6px; }
.pcardwrap { position: relative; }
.pcards.selecting .pcardwrap { cursor: pointer; }
.pcards.selecting .pmove { display: none; }
.pcards.selecting .pcardwrap::after { content: ''; position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.92); border: 2px solid var(--accent); pointer-events: none; z-index: 4; }
.pcards.selecting .pcardwrap.picked::after { content: '✓'; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.pcards.selecting .pcardwrap.picked .pcard { outline: 3px solid var(--accent); outline-offset: -3px; }
.pbox .selbar { top: 62px; }
.trot { position: absolute; top: 6px; right: 40px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); color: #333; box-shadow: 0 1px 4px rgba(0,0,0,.35); font-size: 1rem; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; z-index: 3; }
.ptile:hover .trot, .ptile:focus-within .trot { opacity: 1; }
@media (hover: none) { .trot { opacity: 1; } }
.gal.selecting .trot { display: none; }

/* a photo that can be zoomed inside its frame: --img = picture, --pos = where it is cropped, --bs = its size (cover when not zoomed) */
.zpic { background-color: var(--line); background-image: var(--img); background-position: var(--pos, center); background-size: var(--bs, cover); background-repeat: no-repeat; }
.zoomrow { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; font-size: .85rem; color: var(--muted); }
.zoomrow input[type=range] { flex: 1; }
.zoomrow b { min-width: 3.2em; text-align: right; color: var(--ink); }

/* bullet points in notes and text (a line starting with "- ") */
.place-notes ul, .psec-text ul, .ttext-body ul { white-space: normal; margin: 4px 0; padding-left: 1.3em; list-style: disc; }
.place-notes li, .psec-text li, .ttext-body li { margin: 2px 0; padding-left: 2px; }
.fmtbar button[data-bullets] { font-size: .8rem; }

/* the map key filters the page: picked groups are bold, the others fade */
.legend button.on { background: var(--bg); font-weight: 600; }
.legend button.dim { opacity: .4; }
.legend button[hidden] { display: none; }
.tilewrap[hidden], section.year[hidden] { display: none; }

/* card pictures that can be zoomed in: --img = picture, --pos = where it is cropped, --z = zoom (the same crop at any size) */
.zcov { position: relative; overflow: hidden; }
.zcov::before { content: ''; position: absolute; inset: 0; background: var(--img) var(--pos, center) / cover no-repeat; transform: scale(var(--z, 1)); transform-origin: var(--pos, center); pointer-events: none; }
.acardwrap { position: relative; }
.coverpool { max-height: 280px; overflow-y: auto; }
.back + .split { margin-top: 14px; }

/* the photo inbox on a trip page */
.inbox { margin: 14px 0 8px; padding: 14px; border: 1px dashed var(--line); border-radius: 12px; background: color-mix(in srgb, var(--accent) 4%, var(--card)); }
.inbox .toolbar { align-items: center; margin: 0; }
.inbox .hint { margin: 8px 0 0; }
.inbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 12px; }
.inb { position: relative; padding: 0; aspect-ratio: 1; overflow: hidden; border: 3px solid transparent; border-radius: 10px; background: var(--line); cursor: pointer; }
.inb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.inb.on { border-color: var(--accent); }
.inb-ck { display: none; position: absolute; top: 5px; left: 5px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .8rem; line-height: 22px; text-align: center; }
.inb.on .inb-ck { display: block; }
.inb-open { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: .85rem; line-height: 24px; text-align: center; }
.inb.isvid::after { content: '▶'; position: absolute; left: 6px; bottom: 5px; color: #fff; font-size: .8rem; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
