:root {
    --bg: #fdf8f3;
    --ink: #23202b;
    --muted: #6b6676;
    --line: #ece6df;
    --accent: #7c3aed;
    --card: #fff;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg) radial-gradient(#e7dfd6 1px, transparent 1px) 0 0 / 22px 22px;
    padding-bottom: env(safe-area-inset-bottom);
}

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 16px 12px 96px;
}

@media (min-width: 700px) {
    .wrap {
        padding: 32px 16px 64px;
    }
}

:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
    outline: 2.5px solid var(--btn);
    outline-offset: 2px;
}

h1, h2, h3 {
    font-family: "Fraunces", Georgia, serif;
    margin: 0;
}

/* even heading breaks; no lone words at the end of a paragraph (progressive: ignored where unsupported) */
h1, h2, h3 {
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

button {
    font: inherit;
    cursor: pointer;
    color: inherit;
}

.btn {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 9px 14px;
    font-weight: 500;
    min-height: 40px;
}

.btn:hover {
    background: var(--lavender-soft);
}

.btn.primary {
    background: #e8f1ff;
    border-color: var(--sea-line);
}

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

.empty {
    color: var(--muted);
    text-align: center;
    padding: 30px;
}

/* Header: title, tally, one bar. Rare actions live in the ⋯ menu. */
:root {
    --pink: hsl(334 88% 58%);
    --pink-deep: hsl(334 70% 44%);
    --pink-soft: hsl(334 100% 96%);
    --mango: hsl(36 100% 58%);
    /* Buttons: a deeper bubblegum so white text reads at 4.8:1. Bright --pink stays decorative (bar, underline, pins). */
    --btn: hsl(334 78% 48%);
    --btn-hover: hsl(334 80% 45%);
    --btn-edge: hsl(334 72% 34%);
    /* Type scale (phone-first; older relatives read this): one size per role */
    /* Supporting tones (quieter pass): every literal color in the CSS maps to one of these */
    --danger: #b42318;                      /* destructive actions and errors only */
    --ink-soft: #4b4458;                    /* secondary text that must stay strong */
    --mango-ink: #8a5100;                   /* amber text: 6.6:1 on paper, 4.9:1 on mango tape */
    --pink-line: hsl(334 60% 88%);          /* pink hairlines, dividers, soft edges */
    --pink-line-strong: hsl(334 45% 76%);   /* chevrons, separators, focus-adjacent edges */
    --pink-shadow: hsl(334 50% 45% / .18);  /* soft pink lift under stickers and buttons */
    --lift: hsl(334 30% 15% / .3);          /* deep lift for sheets, toasts and dialogs */
    --hairline: hsl(334 30% 20% / .06);     /* barely-there edges on white */
    --lavender-soft: #f7f4ff;               /* editor and planning surfaces */
    --leaf-line: #cdebd9;                   /* edge of a visited row */
    --scratch: #d9c9c9;                     /* scratched-town stripes */
    --sea: #8fb3c9; --sea-line: #cfe2ee; --sea-ink: #6b8aa0; /* the map's ocean */
    --here: #0a84ff;                        /* "you are here" ring */
    --washi-ink: hsl(334 74% 38%);           /* washi label text: 4.5:1+ on translucent pink tape */
    --sea-paper: #eaf4fa;                   /* the map frame */
    --washi-pink: hsl(334 100% 90% / .8); --washi-mango: hsl(36 100% 85% / .85);
    --fs-fine: 13px;      /* source lines, footnotes, sticker months */
    --fs-meta: 14px;      /* town · date lines, hints, notes */
    --fs-ui: 15px;        /* buttons, chips, tabs, filters */
    --fs-body: 16px;      /* pueblo names, rows, inputs */
    --fs-washi: 17px;     /* lowercase italic tape labels */
    --fs-title: 19px;     /* region, card and dialog titles */
    --fs-headline: 22px;  /* section cards */
    --fs-number: 21px;    /* date-sticker day */
    --fs-tally: 34px;     /* the visited count */
    --fs-icon: 22px;      /* emoji/glyph icons */
    --fs-icon-sm: 18px;
    --spring: cubic-bezier(.3, .7, .4, 1.5);
    /* Layered shadow: several soft shadows read as real depth, one big blur reads as fog */
    --shadow: 0 1px 1px hsl(334 30% 40% / .06), 0 2px 2px hsl(334 30% 40% / .06),
    0 4px 4px hsl(334 30% 40% / .06), 0 8px 8px hsl(334 30% 40% / .06), 0 16px 16px hsl(334 30% 40% / .05);
}

header.hero {
    background: var(--card);
    border: 1px solid var(--pink-line);
    border-radius: 22px;
    padding: 18px 20px 22px;
    box-shadow: var(--shadow);
}

@media (min-width: 700px) {
    header.hero {
        padding: 26px 30px 28px;
    }
}

.hero-top {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: flex-start;
}

h1 {
    font-size: clamp(28px, 7vw, 46px);
    line-height: 1;
    letter-spacing: -.01em;
}

h1 em {
    display: block;
    font-style: italic;
    font-weight: 400;
    color: var(--btn); /* 4.8:1 on white at every size; bright --pink was 3.7:1 at phone width */
    font-size: .78em;
    margin-top: 4px;
}

.tally {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 20px;
}

.tally p {
    margin: 0;
    font-size: var(--fs-ui);
    color: var(--muted);
}

.tally b {
    font-family: "Fraunces", Georgia, serif;
    font-size: var(--fs-tally);
    font-weight: 700;
    margin-right: 2px;
    background: linear-gradient(135deg, var(--pink), var(--mango));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.pct {
    font-size: var(--fs-meta);
    font-weight: 700;
    color: var(--pink-deep);
    font-variant-numeric: tabular-nums;
}

/* Candy-striped progress bar with a little car driving along it */
.bar {
    position: relative;
    height: 14px;
    background: var(--pink-soft);
    border-radius: 99px;
    margin-top: 22px;
    box-shadow: inset 0 1px 2px var(--pink-shadow);
}

.bar > div {
    height: 100%;
    width: 0;
    min-width: 14px;
    border-radius: 99px;
    transition: width .8s var(--spring);
    background: repeating-linear-gradient(-45deg, hsl(0 0% 100% / .22) 0 6px, transparent 6px 12px),
    linear-gradient(90deg, var(--pink), hsl(12 95% 64%), var(--mango));
    background-size: 34px 100%, 100% 100%;
    animation: candy 1.6s linear infinite;
}

@keyframes candy {
    to {
        background-position: 34px 0, 0 0;
    }
}

.car {
    position: absolute;
    bottom: 9px;
    font-size: var(--fs-icon);
    line-height: 1;
    transform: scaleX(-1);
    left: clamp(-4px, calc(var(--p, 0) * 1% - 16px), calc(100% - 24px));
    transition: left .8s var(--spring);
}

.car span {
    display: inline-block;
    animation: putt 1.1s ease-in-out infinite;
}

@keyframes putt {
    50% {
        transform: translateY(-2px) rotate(-3deg);
    }
}

.sync {
    margin-top: 12px;
    font-size: var(--fs-meta);
    border: 0;
    background: #fff7ed;
    color: var(--mango-ink);
    padding: 6px 10px;
    border-radius: 9px;
}

.sync[data-s="saving"] {
    background: transparent;
    color: var(--muted);
    padding-left: 0;
}

.sync[data-s="needkey"] {
    background: #fef2f2;
    color: var(--danger);
    font-weight: 600;
}

/* ⋯ menu */
.more {
    position: relative;
    flex-shrink: 0;
}

.more summary {
    list-style: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    font-size: var(--fs-icon);
    line-height: 1;
    color: var(--muted);
    user-select: none;
}

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

.more summary:hover, .more[open] summary {
    background: #f5f0ea;
    color: var(--ink);
}

.menu {
    position: absolute;
    right: 0;
    top: 44px;
    z-index: 10;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 6px;
    min-width: 190px;
    box-shadow: 0 12px 30px -12px var(--lift);
    display: grid;
}

.menu button {
    text-align: left;
    border: 0;
    background: transparent;
    padding: 11px 12px;
    border-radius: 9px;
    font-size: var(--fs-ui);
}

.menu button:hover {
    background: #f7f3ee;
}

.menu .danger {
    color: var(--danger);
    border-top: 1px solid var(--line);
    border-radius: 0 0 9px 9px;
    margin-top: 4px;
}

/* View switcher */
/* Views: underlined text tabs (navigation), visually distinct from the filters below */
.views {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 14px 0 14px;
    border-bottom: 1px solid var(--line);
}

.tabsbar {
    display: flex;
    gap: 4px;
}

.tabsbar button {
    border: 0;
    background: transparent;
    padding: 12px 10px 10px;
    font-size: var(--fs-body);
    font-weight: 600;
    color: var(--muted);
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1px;
}

.tabsbar button:first-child {
    padding-left: 2px;
}

.tabsbar button[aria-selected="true"] {
    color: var(--pink-deep);
    border-bottom: 4px solid var(--pink);
    border-radius: 2px;
    padding-bottom: 8.5px;
}

.icon-btn {
    border: 0;
    background: transparent;
    height: 40px;
    min-width: 40px;
    border-radius: 12px;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
    padding: 0 8px;
}

.icon-btn:hover {
    background: #f5f0ea;
    color: var(--ink);
}

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

.icon-btn .lbl {
    font-size: var(--fs-ui);
}

@media (max-width: 560px) {
    .icon-btn .lbl {
        display: none;
    }
}

/* Locate card */
#locate-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px 16px;
    margin-bottom: 14px;
    position: relative;
}

#locate-card h2 {
    font-size: var(--fs-title);
    padding-right: 30px;
}

#locate-card .close {
    position: absolute;
    top: 8px;
    right: 8px;
    border: 0;
    background: transparent;
    width: 36px;
    height: 36px;
    font-size: var(--fs-icon-sm);
}

#locate-card .near {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

#locate-card .near button {
    border: 1px solid var(--line);
    background: var(--lavender-soft);
    border-radius: 99px;
    padding: 6px 12px;
    font-size: var(--fs-meta);
}

#locate-card .btn {
    margin-top: 10px;
}

/* Checklist */
/* Filters (soft segmented control) + search. Phones: search hides behind an icon. */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.filters {
    display: flex;
    background: #f1eae3;
    border-radius: 12px;
    padding: 3px;
    gap: 2px;
}

.tab {
    border: 0;
    background: transparent;
    border-radius: 9px;
    padding: 7px 12px;
    font-size: var(--fs-ui);
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

.tab span {
    font-size: var(--fs-fine);
    font-weight: 400; /* secondary by weight, not by fading (opacity dropped it to 3:1) */
    margin-left: 2px;
    font-variant-numeric: tabular-nums;
}

.tab[aria-pressed="true"] {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(60, 40, 20, .15);
}

.search {
    flex: 1;
    min-width: 0;
    max-width: 320px;
    margin-left: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 9px 12px;
    font: inherit;
    font-size: var(--fs-body);
    background: #fff;
}

.search-toggle {
    display: none;
    margin-left: auto;
}

.search-toggle .i-close {
    display: none;
}

@media (max-width: 560px) {
    .tab {
        padding: 7px 10px;
    }

    .search {
        display: none;
        max-width: none;
        margin-left: 0;
    }

    .search::-webkit-search-cancel-button {
        display: none;
    }

    /* our ✕ closes and clears */
    .search-toggle {
        display: inline-flex;
    }

    .toolbar.searching .filters {
        display: none;
    }

    .toolbar.searching .search {
        display: block;
    }

    .toolbar.searching .i-search {
        display: none;
    }

    .toolbar.searching .i-close {
        display: block;
    }
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
}

@media (min-width: 700px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1000px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.region {
    border-radius: 22px;
    padding: 16px;
    position: relative;
    border: 1px solid var(--hairline);
}

.region::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 50%;
    width: 76px;
    height: 16px;
    transform: translateX(-50%) rotate(-1.5deg);
    background: var(--tape);
    opacity: .8;
    border-radius: 2px;
}

.region-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
}

.region h2 {
    font-size: var(--fs-title);
}

.count {
    font-size: var(--fs-fine);
    font-weight: 600;
    background: #fff;
    border: 1px solid var(--line);
    padding: 2px 8px;
    border-radius: 99px;
    white-space: nowrap;
}

.town {
    background: #fff;
    border-radius: 12px;
    padding: 8px 8px 8px 10px;
    margin-bottom: 7px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.town label {
    display: flex;
    gap: 10px;
    align-items: center;
    cursor: pointer;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
    min-height: 30px;
}

.town input[type=checkbox] {
    width: 20px;
    height: 20px;
    accent-color: var(--check);
    margin: 0;
}

.town .name {
    font-weight: 500;
}

.chip {
    font-size: var(--fs-fine);
    border: 1px solid var(--line);
    border-radius: 99px;
    padding: 2px 8px;
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 170px;
}

.chip.date {
    color: #18794e;
    border-color: var(--leaf-line);
    background: #f3fbf6;
    font-size: var(--fs-fine);
    font-weight: 600;
}

.note-line {
    width: 100%;
    padding-left: 30px;
    font-size: var(--fs-ui);
    line-height: 1.35;
    color: var(--ink-soft);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.pencil {
    border: 0;
    background: #f3eefe;
    color: var(--accent);
    width: 34px;
    height: 34px;
    border-radius: 99px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

/* Editor: stacked, full-width fields (phones first) */
.note-edit {
    width: 100%;
    display: grid;
    gap: 10px;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.note-edit label {
    display: grid;
    gap: 4px;
}

.note-edit label span {
    font-size: var(--fs-meta);
    font-weight: 600;
    color: var(--muted);
}

.note-edit input, .note-edit textarea {
    width: 100%;
    font: inherit;
    font-size: var(--fs-body);
    line-height: 1.4;
    color: var(--ink);
    padding: 9px 11px;
    border: 1px solid #d9d2ca;
    border-radius: 12px;
    background: #fff;
}

.note-edit textarea {
    resize: vertical;
    min-height: 72px;
}

.note-edit input:focus, .note-edit textarea:focus {
    outline: 2px solid var(--pink-line-strong);
    outline-offset: 1px;
    border-color: transparent;
}

.edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.edit-actions .btn {
    min-width: 88px;
}

.scratched {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 18px 22px;
    margin-top: 18px;
}

.scratched h2 {
    font-size: var(--fs-title);
}

.scratched p {
    margin: 2px 0 12px;
    font-size: var(--fs-fine);
    color: var(--muted);
}

.scratched span {
    display: inline-block;
    background: var(--pink-soft);
    border: 1px solid var(--pink-line);
    color: var(--muted);
    padding: 4px 12px;
    border-radius: 99px;
    margin: 0 6px 6px 0;
    font-size: var(--fs-meta);
}

/* Reorder mode (drag by handle only) */
.reorder-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 560px;
    margin: 0 auto 12px;
}

.reorder-hint {
    color: var(--muted);
    font-size: var(--fs-ui);
    margin: 0;
}

.reorder-list {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    max-width: 560px;
    display: grid;
    gap: 8px;
}

.rrow {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 8px 4px;
    border-radius: 14px;
    background: var(--bg-r);
    border: 1px solid var(--hairline);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.rrow.dragging {
    z-index: 5;
    box-shadow: 0 14px 30px -10px var(--lift);
    scale: 1.02;
    transition: scale .15s;
}

.rrow .handle {
    touch-action: none;
    cursor: grab;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    font-size: var(--fs-icon);
    color: var(--muted);
    border-radius: 12px;
}

.rrow.dragging .handle {
    cursor: grabbing;
}

.rrow .rname {
    flex: 1;
    font-weight: 600;
    min-width: 0;
}

.rrow .arrows {
    display: flex;
    gap: 4px;
}

.rrow .arrows button {
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
}

.rrow .arrows button:disabled {
    opacity: .35;
}

body.reordering .toolbar {
    display: none;
}

/* Timeline: the family's travel journal. Washi month labels, region-tinted entries,
   a date sticker and a postmark stamp per visit; cards stay flat (The Tilt Rule). */
.tl-month {
    margin-bottom: 26px;
}

.tl-washi {
    margin: 0 0 12px;
    font-size: inherit;
}

.tl-washi span {
    display: inline-block;
    font-family: "Fraunces", Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: var(--fs-washi);
    color: var(--washi-ink);
    padding: 3px 14px 4px;
    transform: rotate(-2deg);
    background: var(--washi-pink);
    border-radius: 2px;
    clip-path: polygon(3% 0, 97% 4%, 100% 50%, 97% 96%, 3% 100%, 0 50%);
}

.tl-month:nth-child(even) .tl-washi span {
    transform: rotate(1.5deg);
    background: var(--washi-mango);
    color: var(--mango-ink);
}

.tl-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.tl-entry {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--t);
    border-radius: 18px;
    padding: 12px 14px;
    position: relative;
    box-shadow: var(--shadow);
}

.tl-entry .date-sticker {
    background: #fff;
}

.tl-entry.alt .date-sticker {
    transform: rotate(-2.5deg);
}

.tl-body {
    flex: 1;
    min-width: 0;
}

.tl-body b {
    display: block;
    font-size: var(--fs-body);
}

.tl-meta {
    display: block;
    font-size: var(--fs-meta);
    color: var(--ink-soft);
    margin-top: 2px;
}

/* their own words, in the scrapbook's handwriting */
.tl-note {
    margin: 6px 0 0;
    font-family: "Fraunces", Georgia, serif;
    font-style: italic;
    font-size: var(--fs-body);
    color: var(--ink);
}

/* postmark: a sticker, so it may tilt */
.tl-stamp {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 2px dashed var(--c);
    color: var(--c);
    font-weight: 700;
    font-size: var(--fs-icon-sm);
    transform: rotate(-12deg);
    opacity: .9;
    transition: transform .45s var(--spring);
}

.tl-entry.alt .tl-stamp {
    transform: rotate(9deg);
}

.tl-entry:hover .tl-stamp {
    transform: rotate(0) scale(1.12);
}

/* milestones on the way to 75: a ribbon of tape across the page */
.tl-milestone {
    text-align: center;
    padding: 10px 14px;
    margin: 4px 0;
    font-size: var(--fs-ui);
    color: var(--ink);
    background: linear-gradient(135deg, var(--pink-soft), hsl(36 100% 96%));
    border: 1.5px dashed var(--pink-line-strong);
    border-radius: 14px;
}

.tl-milestone b {
    font-family: "Fraunces", Georgia, serif;
    font-style: italic;
    font-weight: 400;
    color: var(--btn);
    margin-right: 4px;
}

@media (prefers-reduced-motion: reduce) {
    .tl-stamp, .tl-entry:hover .tl-stamp { transition: none; }
}

.tl-stats {
    color: var(--muted);
    margin: 0 0 16px;
}

/* Map */
.map-box {
    position: relative;
    background: var(--sea-paper);
    border: 1px solid var(--line);
    border-radius: 22px;
    overflow: hidden;
}

.map-scroll {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 70vh;
    scrollbar-width: thin;
    touch-action: pan-x pan-y;
    overscroll-behavior: contain;
}

.map-scroll svg {
    display: block;
    height: auto;
}

.map-tools {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    z-index: 2;
}

.map-tools .btn {
    width: 34px;
    min-height: 34px;
    height: 34px;
    padding: 0;
    font-size: var(--fs-icon-sm);
    background: rgba(255, 255, 255, .85);
}

@media (min-width: 700px) {
    .map-tools .btn {
        width: 40px;
        height: 40px;
        font-size: var(--fs-icon-sm);
    }
}

.map-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px 16px;
    margin-top: 12px;
    min-height: 64px;
}

.map-card h2 {
    font-size: var(--fs-title);
}

.map-card p {
    margin: 4px 0 0;
}

.map-card .btn {
    margin-top: 10px;
}

/* Region progress card (also the map legend) */
.legend {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 12px;
    margin-top: 12px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px 16px;
}

@media (min-width: 700px) {
    .legend {
        grid-template-columns: 1fr 1fr;
        padding: 14px 16px;
    }
}

.lg-head, .lg-foot {
    grid-column: 1 / -1;
}

.lg-head {
    padding: 2px 8px 8px;
}

.lg-head h2 {
    font-size: var(--fs-title);
}

.lg-head p {
    margin: 2px 0 0;
    font-size: var(--fs-meta);
}

.lg-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    align-items: center;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 9px 8px;
    border-radius: 12px;
    font-size: var(--fs-ui);
}

.lg-row:hover {
    background: #faf7f4;
}

.lg-row.on {
    background: var(--lavender-soft);
    box-shadow: inset 0 0 0 1.5px #c4b5fd;
}

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

.lg-count {
    font-size: var(--fs-meta);
    font-weight: 600;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.lg-bar {
    grid-column: 1 / -1;
    height: 8px;
    border-radius: 99px;
    background: var(--t);
    box-shadow: inset 0 0 0 1px var(--hairline);
    overflow: hidden;
}

.lg-bar i {
    display: block;
    height: 100%;
    background: var(--c);
    border-radius: 99px;
}

.lg-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 8px 2px;
    font-size: var(--fs-meta);
    color: var(--muted);
}

.lg-foot i {
    width: 22px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
    background: repeating-linear-gradient(45deg, #f3eded 0 3px, var(--scratch) 3px 5px);
}

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 10px 10px 10px 16px;
    border-radius: 14px;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: 0 10px 30px -8px var(--lift);
    z-index: 20;
    max-width: calc(100vw - 24px);
    font-size: var(--fs-ui);
}

.toast.err {
    background: var(--danger);
}

.toast button {
    border: 0;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 12px;
}

/* Dialogs */
dialog {
    border: 0;
    border-radius: 18px;
    padding: 22px;
    width: min(420px, calc(100vw - 24px));
    box-shadow: 0 20px 50px -10px var(--lift);
}

dialog h2 {
    font-size: var(--fs-title);
    margin-bottom: 6px;
}

dialog p {
    color: var(--muted);
    font-size: var(--fs-ui);
    margin: 0 0 14px;
}

dialog input {
    width: 100%;
    font: inherit;
    font-size: var(--fs-body);
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 12px;
}

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

#history-list {
    max-height: 55vh;
    overflow: auto;
    display: grid;
    gap: 8px;
}

.hrow {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 10px;
}

.hrow div {
    flex: 1;
    font-size: var(--fs-ui);
}

.hrow small {
    color: var(--muted);
    display: block;
}

@media print {
    body {
        background: #fff;
    }

    .more, .toolbar, .pencil, .toast, .note-edit, .views, #locate-card, .map-tools, .sync {
        display: none !important;
    }

    .region {
        border: 1px solid #ccc;
    }

    .map-scroll {
        max-height: none;
        overflow: visible;
    }
}

/* ================= Bubbly layer ================= */

/* Pressable buttons: a darker "edge" underneath that the button sinks into */
.btn {
    position: relative;
    border: 1.5px solid var(--pink-line);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 3px 0 var(--pink-line);
    transform: translateY(-1px);
    transition: transform .5s var(--spring), box-shadow .5s var(--spring), background .2s;
}

.btn:hover {
    background: #fff;
    transform: translateY(-3px);
    box-shadow: 0 5px 0 var(--pink-line);
    transition-duration: .25s;
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 var(--pink-line);
    transition-duration: .04s;
}

.btn.primary {
    background: var(--btn);
    color: #fff;
    font-weight: 700;
    border-color: var(--btn-edge);
    box-shadow: 0 3px 0 var(--btn-edge);
}

.btn.primary:hover {
    background: var(--btn-hover);
    box-shadow: 0 5px 0 var(--btn-edge);
}

.btn.primary:active {
    box-shadow: 0 0 0 var(--btn-edge);
}

/* Filters: the selected option is a little pink jelly-bean */
.filters {
    background: var(--pink-soft);
}

.tab {
    min-height: 36px; /* + the 3px track = a 42px target */
    transition: transform .4s var(--spring), background .2s, color .2s;
}

.tab:hover {
    color: var(--pink-deep);
}

.tab:active {
    transform: scale(.94);
}

.tab[aria-pressed="true"] {
    background: #fff;
    color: var(--pink-deep);
    font-weight: 700;
    box-shadow: 0 2px 0 var(--pink-line), 0 3px 8px var(--pink-shadow);
}

/* Boops: tiny springy wiggles on hover / tap */
.pencil, .icon-btn, .more summary {
    transition: transform .45s var(--spring), background .2s, color .2s;
}

/* 75 of these: quiet until touched. Muted plum glyph, no disc; 44px target for older fingers. */
.pencil {
    width: 44px;
    height: 44px;
    margin: -5px -6px -5px 0;
    background: transparent;
    color: var(--muted);
    font-size: var(--fs-icon-sm);
}

.pencil:hover, .pencil:focus-visible {
    transform: rotate(-14deg) scale(1.12);
    background: var(--pink-soft);
    color: var(--pink-deep);
}

.icon-btn:hover, .more summary:hover {
    transform: rotate(-8deg) scale(1.1);
    color: var(--pink-deep);
    background: var(--pink-soft);
}

.pencil:active, .icon-btn:active {
    transform: scale(.88);
    transition-duration: .08s;
}

.more[open] summary {
    background: var(--pink-soft);
    color: var(--pink-deep);
}

/* Bubbly checkboxes that pop when checked */
.town input[type=checkbox] {
    appearance: none;
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    margin: 0;
    flex-shrink: 0;
    border-radius: 9px;
    border: 2px solid var(--check); /* full region shade: ≥3:1 on white */
    background: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .2s, border-color .2s, transform .45s var(--spring);
}

.town input[type=checkbox]:hover {
    transform: scale(1.08);
    border-color: var(--check);
}

.town input[type=checkbox]::after {
    content: "";
    width: 12px;
    height: 7px;
    margin-top: -3px;
    border: 3px solid #fff;
    border-top: 0;
    border-right: 0;
    transform: rotate(-45deg) scale(0);
    transition: transform .35s var(--spring);
}

.town input[type=checkbox]:checked {
    background: var(--check);
    border-color: var(--check);
}

.town input[type=checkbox].just:checked {
    animation: pop .45s var(--spring);
}

.town input[type=checkbox]:checked::after {
    transform: rotate(-45deg) scale(1);
}

@keyframes pop {
    0% {
        transform: scale(.7);
    }
    60% {
        transform: scale(1.18);
    }
    100% {
        transform: scale(1);
    }
}

/* Sparkle burst (spawned by app.js when a town is checked off) */
.sparkle {
    position: fixed;
    pointer-events: none;
    z-index: 50;
    font-size: var(--s, 12px);
    line-height: 1;
    color: var(--c, var(--pink));
    animation: sparkle .7s cubic-bezier(.2, .8, .3, 1) forwards;
}

@keyframes sparkle {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0);
        opacity: 1;
    }
    60% {
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(160deg);
        opacity: 0;
    }
}

/* Visited rows get a faint wash of their region color */
.town.done {
    background: color-mix(in srgb, var(--check) 6%, white);
}

@media (prefers-reduced-motion: reduce) {
    /* nothing moves, but state changes still read: colors and fades keep their (short) transitions */
    *, *::before, *::after {
        animation: none !important;
        transition-property: opacity, color, background-color, border-color, box-shadow !important;
    }

    .sparkle {
        display: none;
    }
}

/* ================= Install the app ================= */
.install-card {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--pink-soft), hsl(36 100% 96%));
    border: 1.5px solid var(--pink-line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    animation: installIn .6s var(--spring);
}

@keyframes installIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(.97);
    }
}

.install-card img {
    border-radius: 12px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px var(--pink-shadow);
    transform: rotate(-4deg);
}

.install-txt {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 2px;
}

.install-txt b {
    font-size: var(--fs-ui);
}

.install-txt span {
    font-size: var(--fs-meta);
    color: var(--muted);
    line-height: 1.35;
}

.install-btns {
    display: grid;
    gap: 2px;
    justify-items: center;
    flex-shrink: 0;
}

.install-later {
    border: 0;
    background: none;
    font: inherit;
    font-size: var(--fs-fine);
    color: var(--muted);
    padding: 4px;
    cursor: pointer;
}

.install-card[data-kind="ios"] #install-go::after {
    content: " ›";
}

#ios-install h2 {
    margin-bottom: 4px;
}

.steps {
    list-style: none;
    margin: 8px 0 6px;
    padding: 0;
    display: grid;
    gap: 14px;
}

.steps li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: var(--fs-body);
    line-height: 1.4;
}

.steps small {
    display: block;
    color: var(--muted);
    font-size: var(--fs-meta);
    margin-top: 2px;
}

.step-n {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--btn);
    color: #fff;
    font-weight: 700;
    display: grid;
    place-items: center;
    box-shadow: 0 2px 0 var(--btn-edge);
}

.ios-glyph {
    width: 24px;
    height: 24px;
    vertical-align: -6px;
    margin-left: 4px;
    fill: none;
    stroke: var(--here);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn:focus:not(:focus-visible) {
    outline: none;
}

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

/* ================= Language switch ================= */
.hero-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.lang {
    display: flex;
    background: var(--pink-soft);
    border-radius: 99px;
    padding: 3px;
}

.lang button {
    border: 0;
    background: transparent;
    font: inherit;
    font-size: var(--fs-meta);
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--muted);
    min-width: 40px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 99px;
    cursor: pointer;
    transition: background .2s, color .2s, transform .35s var(--spring);
}

.lang button:hover {
    color: var(--pink-deep);
}

.lang button[aria-pressed="true"] {
    background: #fff;
    color: var(--pink-deep);
    box-shadow: 0 1px 0 var(--pink-line), 0 2px 6px var(--pink-shadow);
}

.lang button:active {
    transform: scale(.92);
}

@media print {
    .lang {
        display: none;
    }
}

/* ================= Scrapbook map ================= */
.map-box {
    background: var(--sea-paper);
}

.map-scroll .sea {
    font-family: "Fraunces", Georgia, serif;
    font-style: italic;
    font-size: 22px;
    fill: var(--sea);
    text-anchor: middle;
    letter-spacing: .08em;
    pointer-events: none;
}

.map-scroll .compass circle {
    fill: #fff;
    stroke: var(--sea-line);
    stroke-width: 1.5;
}

.map-scroll .compass path {
    fill: var(--pink);
}

.map-scroll .compass text {
    font: 700 9px "Plus Jakarta Sans", sans-serif;
    fill: var(--sea-ink);
    text-anchor: middle;
}

/* paper cut-out: the island's white edge + soft shadow sits under the pueblos */
.map-scroll .island-edge {
    fill: #fff;
    stroke: #fff;
    stroke-width: 9px;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.map-scroll path.town {
    stroke: #fff;
    stroke-width: .7px;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
    transition: fill .3s, opacity .3s;
}

.map-scroll path.town:hover {
    filter: brightness(.97);
}

.map-scroll path.town.dim {
    opacity: .25;
}

.map-scroll .region-edges {
    fill: none;
    stroke: #fff;
    stroke-width: 2.4px;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.map-scroll .hl-outline {
    fill: none;
    stroke-width: 3px;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.map-scroll .sel-outline {
    fill: none;
    stroke: var(--ink);
    stroke-width: 2.5px;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

/* ✓ stamps on visited pueblos */
.map-scroll .stamp circle {
    fill: #fff;
    stroke: var(--c);
    stroke-width: 1.6;
}

.map-scroll .stamp path {
    fill: none;
    stroke: var(--c);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.map-scroll .stamp {
    pointer-events: none;
    filter: drop-shadow(0 1px 1px rgb(0 0 0 / .18));
}

.map-scroll .stamp.pop {
    animation: stampPop .6s var(--spring);
    transform-box: fill-box;
    transform-origin: center;
}

@keyframes stampPop {
    0% {
        transform: scale(0) rotate(-30deg);
    }
    60% {
        transform: scale(1.4) rotate(8deg);
    }
    100% {
        transform: scale(1);
    }
}

/* pueblo names (white halo so they read on any color) */
.map-scroll #labels text {
    font-family: "Plus Jakarta Sans", sans-serif;
    font-weight: 600;
    fill: var(--ink-soft);
    text-anchor: middle;
    stroke: #fff;
    paint-order: stroke;
    stroke-linejoin: round;
    pointer-events: none;
}

/* event pins: white bubble with the event's icon */
.map-scroll .ev-pin {
    cursor: pointer;
}

.map-scroll .pin-in {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    transition: transform .4s var(--spring);
    filter: drop-shadow(0 2px 2px rgb(120 40 80 / .3));
}

.map-scroll .ev-pin:hover .pin-in {
    transform: scale(1.18) rotate(-6deg);
}

.map-scroll .pin-body {
    fill: #fff;
    stroke: var(--pink);
    stroke-width: 2;
}

.map-scroll .pin-ico {
    font-size: var(--fs-ui);
    text-anchor: middle;
    dominant-baseline: middle;
}

.map-scroll .pin-badge {
    fill: var(--pink);
    stroke: #fff;
    stroke-width: 1.5;
}

.map-scroll .pin-n {
    font: 700 9px "Plus Jakarta Sans", sans-serif;
    fill: #fff;
    text-anchor: middle;
}

.map-hint i {
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
}

/* Map pueblo card: its actions side by side */
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
