:root {
    --poke-red: #c62828;
    --poke-red-light: #ffcdd2;
    --poke-dark: #1a1a2e;
    --poke-green: #43a047;
    --poke-yellow: #fdd835;
    --poke-white: #ffffff;
    --poke-grey: #f0f2f5;
    --poke-grey-mid: #c8ccd4;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --desktop-content-width: 1400px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --canvas: #f0f2f5;
    --surface: #ffffff;
    --surface-subtle: #f7f8fa;
    --text: #1a1a2e;
    --text-muted: #565c6a;
    --border: #d5d9e1;
    --caught-surface: #f4faf4;
    --action-hover: #a92121;
    --action-soft: #fff0ee;
    --card-radius: var(--radius-lg);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.14);
    --transition: 0.15s ease;
    --save-menu-bg: var(--surface);
    --save-menu-shadow-opacity: 0.1;
    --la-badge-text: #7a5500;
    --la-badge-bg: #fff3bf;
    --la-badge-border: rgba(184,134,11,0.5);
    --focus-ring: #1565c0;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, select { touch-action: manipulation; }
button, input, select, textarea, a, [tabindex] { scroll-margin-top: 140px; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.modern-header :focus-visible, .nav-sticky-wrapper :focus-visible { outline-color: var(--poke-yellow); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 10000; transform: translateY(-160%); background: white; color: var(--poke-dark); padding: 12px 18px; border-radius: 10px; font-weight: 800; }
.skip-link:focus { transform: translateY(0); }

/* ══════════════════════════════════
   PIXEL SPRITE ICONS (replace emoji)
══════════════════════════════════ */
.pixel-icon {
    width: 1.3em;
    height: 1.3em;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    vertical-align: -0.3em;
    object-fit: contain;
}
.pixel-icon-lg { width: 40px; height: 40px; vertical-align: middle; }

/* Reserve scrollbar space so short and long tabs share the same alignment. */
html { background: var(--surface); scrollbar-gutter: stable; }
html:has(body.dark-mode) { background: #1b1d29; }

body {
    font-family: 'Nunito', sans-serif;
    background: var(--canvas);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    min-height: 100dvh;
    padding-bottom: calc(110px + env(safe-area-inset-bottom));
    color: var(--text);
}

/* ══════════════════════════════════
   HEADER
══════════════════════════════════ */
.modern-header {
    background: var(--poke-red);
    padding: var(--space-4) var(--space-4) var(--space-3);
    padding-top: calc(var(--space-4) + env(safe-area-inset-top));
    position: relative;
    overflow: hidden;
}
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
    gap: var(--space-3);
}
.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.header-inner, .search-field { min-width: 0; }
.header-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.header-title span {
    display: inline-block;
    width: 22px; height: 22px;
    background: white;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 6px;
    position: relative;
}
.header-title span::after {
    content: '';
    position: absolute;
    top: 50%; left: 0; right: 0;
    height: 2px;
    background: var(--poke-dark);
    transform: translateY(-50%);
}

.settings-tab-btn {
    width: 44px; height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.5);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.settings-tab-btn:hover, .settings-tab-btn:active { background: rgba(0,0,0,0.12); }

#poke-search {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: none;
    outline: none;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    background: white;
    color: var(--poke-dark);
    min-height: 44px;
}
#poke-search::placeholder { color: #656b79; }
#poke-search:focus-visible { outline: 3px solid var(--poke-yellow); outline-offset: 3px; }

.header-view-btns {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.view-btn {
    flex: 1;
    padding: 7px 0;
    border-radius: var(--radius-md);
    border: 2px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.15);
    color: white;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.3px;
    min-height: 44px;
}
.view-btn:active, .view-btn.active { background: rgba(255,255,255,0.35); border-color: white; }

/* ══════════════════════════════════
   STICKY NAV
══════════════════════════════════ */
.nav-sticky-wrapper {
    position: sticky;
    top: env(safe-area-inset-top);
    z-index: 2500;
    background: var(--poke-dark);
    border-bottom: 1px solid #45455a;
}

/* Covers the safe-area gap so the header never bleeds above the sticky nav */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top);
    background: var(--poke-dark);
    z-index: 3000;
    pointer-events: none;
}
#region-nav {
    display: flex;
    overflow-x: auto;
    padding: 8px 10px;
    gap: 8px;
    scroll-snap-type: x mandatory;
}
#pref-nav {
    display: flex;
    overflow-x: auto;
    padding: 7px 10px;
    gap: 7px;
    background: #2c2c44;
    border-top: 1px solid rgba(255,255,255,0.08);
}
#region-nav::-webkit-scrollbar,
#pref-nav::-webkit-scrollbar { display: none; }

#region-nav button {
    padding: 7px 14px;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    scroll-snap-align: start;
    letter-spacing: 0.3px;
    min-height: 44px;
}
#region-nav button.active {
    background: var(--poke-red);
    color: white;
    border-color: rgba(255,255,255,0.3);
}
#region-nav button:hover { background: #49495e; color: white; }
#region-nav button.active:hover { background: var(--action-hover); }

#pref-nav button {
    padding: 5px 12px;
    border-radius: var(--radius-md);
    border: none;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6);
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    scroll-snap-align: start;
    min-height: 44px;
}
#pref-nav button.active {
    background: var(--poke-green);
    color: white;
}

/* Collection context and controls stay consistent across list, journal, and map. */
.collection-toolbar-wrap { border-bottom: 1px solid var(--divider); }
.collection-toolbar {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 12px 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}
.collection-copy { flex: 1 1 240px; min-width: 0; }
#pref-nav:empty { display: none; }
#collection-heading { font-family: 'Fredoka', sans-serif; font-size: clamp(1.35rem, 3vw, 1.8rem); line-height: 1.2; }
.collection-tagline { margin-top: var(--space-1); color: var(--text-muted); font-size: 0.85rem; line-height: 1.5; }
#results-summary { margin-top: var(--space-2); color: var(--text-muted); font-size: 0.85rem; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.collection-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); min-width: 0; }
.collection-sort-field { display: grid; gap: var(--space-1); min-width: 0; }
.collection-sort-field label { color: var(--text-muted); font-size: 0.75rem; font-weight: 800; }
#collection-sort { width: 100%; min-width: 140px; max-width: 240px; min-height: 44px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text); font: 700 0.85rem 'Nunito', sans-serif; cursor: pointer; }
#collection-sort:disabled { cursor: default; color: var(--text-muted); }
.collection-scope-hint { max-width: 70ch; margin-top: var(--space-2); color: var(--text-muted); font-size: 0.8rem; line-height: 1.5; }
.active-filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); flex-basis: 100%; min-width: 0; }
.collection-copy .active-filter-chips { margin-top: var(--space-2); }
.active-filter-chip { display: inline-flex; align-items: center; justify-content: space-between; gap: var(--space-2); max-width: 100%; min-width: 0; min-height: 44px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-muted); font: 700 0.78rem 'Nunito', sans-serif; line-height: 1.4; text-align: left; }
button.active-filter-chip { cursor: pointer; transition: background var(--transition), border-color var(--transition); }
button.active-filter-chip:hover, button.active-filter-chip:active { background: var(--action-soft); border-color: var(--poke-red); color: var(--text); }
.active-filter-chip.is-fixed { background: var(--surface-subtle); border-color: transparent; }
.filter-chip-label { min-width: 0; overflow-wrap: anywhere; }
.filter-chip-remove { flex-shrink: 0; font-size: 1.1rem; line-height: 1; }
.catch-filter-field { display: grid; gap: 5px; }
.catch-filter-field label { font-size: 0.75rem; font-weight: 800; color: #565c6a; }
#catch-filter, .filter-reset-btn { min-height: 44px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); font: 700 0.85rem 'Nunito', sans-serif; color: var(--text); background: var(--surface); }
#catch-filter { min-width: 125px; cursor: pointer; }
.filter-reset-btn { cursor: pointer; }
.filter-reset-btn:hover, .filter-reset-btn:active { background: var(--action-soft); border-color: var(--poke-red); }
.setup-status { max-width: 1400px; margin: 0 auto; padding: 0 12px; }
.app-status { margin: var(--space-3) 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text-muted); line-height: 1.5; }
.setup-status > button { margin: 0 0 12px; }
.photo-storage-notice { max-width: 1376px; margin: 12px auto; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text); }
.photo-storage-notice p { margin-bottom: 12px; line-height: 1.5; overflow-wrap: anywhere; }

/* ══════════════════════════════════
   LID CONTAINER — HORIZONTAL CARDS
══════════════════════════════════ */
#lid-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 12px;
}

/* ── HORIZONTAL CARD ── */
.lid-card {
    --lid-art-size: 100px;
    --lid-inset: 10px;
    --catch-size: 68px;
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 0;
    display: grid;
    grid-template-columns: calc(var(--lid-art-size) + var(--lid-inset) * 2) minmax(0, 1fr) auto;
    align-items: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    transition: background var(--transition), border-color var(--transition);
    margin-bottom: var(--space-3);
}

/* Caught status uses a green edge and the catch control. */
.lid-card.is-caught-card {
    background: var(--caught-surface);
}
.lid-card.is-caught-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    background: var(--poke-green);
    border-radius: var(--card-radius) 0 0 var(--card-radius);
}
/* Journal visits already display their status in the header and date. */
.lid-card.journal-mode.is-caught-card::before {
    content: none;
}

/* Lid image wrapper — stamp is absolutely positioned inside */
.lid-img-wrap {
    position: relative;
    width: var(--lid-art-size);
    height: var(--lid-art-size);
    margin: var(--lid-inset);
    flex-shrink: 0;
    cursor: pointer;
}
.lid-img-wrap:active .lid-img { transform: scale(0.92); }
.lid-card .lid-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    background: var(--surface-subtle);
    border: 2px solid var(--border);
    display: block;
    transition: border-color 0.2s;
}
.lid-card.is-caught-card .lid-img {
    border-color: rgba(67,160,71,0.35);
}

/* Card text block */
.card-text {
    flex: 1;
    min-width: 0;
    padding: 12px 8px 12px 2px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.city-label {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--poke-dark);
    letter-spacing: 0.3px;
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
}
.poke-name {
    font-size: 0.85rem;
    color: #626978;
    font-weight: 600;
    margin-top: 2px;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.pref-tag {
    font-size: 0.68rem;
    color: #b52724;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 3px;
    opacity: 1;
}

/* Card action row */
.card-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 6px 10px;
    border-top: 1px solid var(--divider);
    background: var(--surface-subtle);
    align-items: center;
}
.card-actions .mini-btn { justify-content: center; min-width: 0; width: 100%; font-size: 0.8rem; }
.map-btn {
    margin-top: 4px;
    align-self: flex-start;
}
.mini-btn {
    background: var(--surface-subtle);
    border: none;
    border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-2);
    font-size: 0.7rem;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    color: var(--text-muted);
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-height: 44px;
    min-width: 44px;
    line-height: 1.2;
}
.mini-btn:hover, .mini-btn:active { color: var(--text); background: var(--action-soft); }


/* ══════════════════════════════════
   POKÉBALL CATCH BUTTON
══════════════════════════════════ */
.catch-col {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 12px 12px 12px 8px;
}
/* Pokeball + label stay stacked in their own column */
.catch-col-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.catch-btn {
    width: var(--catch-size, 68px);
    height: var(--catch-size, 68px);
    border-radius: 50%;
    border: 3px solid var(--poke-dark);
    background: white;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, border-color 0.2s ease;
    flex-shrink: 0;
}
.catch-btn:active { transform: scale(0.88); }

/* Pokéball halves */
.catch-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 50%;
    background: #ddd;
    transition: background 0.2s ease;
}
.catch-btn::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 34%; height: 34%;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--poke-dark);
    z-index: 2;
    transition: border-color 0.2s ease;
}

/* Dividing line */
.catch-btn .pb-line {
    position: absolute;
    top: 50%; left: 0; right: 0;
    height: 3px;
    background: var(--poke-dark);
    transform: translateY(-50%);
    z-index: 1;
    transition: background 0.2s ease;
}

/* Caught state */
.catch-btn.is-caught { border-color: var(--poke-dark); }
.catch-btn.is-caught::before { background: var(--poke-red); }
.catch-btn.is-caught::after { border-color: var(--poke-dark); background: white; }
.catch-btn.is-caught .pb-line { background: var(--poke-dark); }

/* Catch label */
.catch-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #656b79;
    transition: color 0.2s;
}
.catch-btn.is-caught + .catch-label { color: #287a32; }


/* Shake animation on catch */
@keyframes pokeball-catch {
    0%   { transform: scale(1) rotate(0deg); }
    15%  { transform: scale(1.15) rotate(-8deg); }
    30%  { transform: scale(1.15) rotate(8deg); }
    45%  { transform: scale(1.15) rotate(-8deg); }
    60%  { transform: scale(1.15) rotate(0deg); }
    80%  { transform: scale(0.9); }
    100% { transform: scale(1); }
}
.catch-btn.catching { animation: pokeball-catch 0.55s ease forwards; }

/* ══════════════════════════════════
   STAMP OVERLAY
══════════════════════════════════ */
.stamp-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0) rotate(-15deg);
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transition: none;
}
.stamp-overlay.stamp-show {
    animation: stampIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.stamp-overlay.stamp-hide {
    animation: stampOut 0.4s ease forwards;
}

.stamp-inner {
    border: 4px solid var(--poke-green);
    border-radius: 8px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.95);
    transform: rotate(-12deg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.stamp-inner span {
    display: block;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--poke-green);
    text-transform: uppercase;
    letter-spacing: 2px;
    white-space: nowrap;
}
.stamp-inner .stamp-stars {
    font-size: 0.7rem;
    text-align: center;
    color: var(--poke-green);
    letter-spacing: 4px;
}

@keyframes stampIn {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(2.2) rotate(-15deg); }
    60%  { opacity: 1; transform: translate(-50%, -50%) scale(0.9) rotate(-12deg); }
    75%  { transform: translate(-50%, -50%) scale(1.05) rotate(-12deg); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-12deg); }
}
@keyframes stampOut {
    0%   { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-12deg); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8) rotate(-12deg); }
}

/* ══════════════════════════════════
   PHOTO PREVIEW (inline in card)
══════════════════════════════════ */
.user-photo-preview {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 10px;
    margin-top: 8px;
    display: none;
    border: 1.5px solid var(--border);
}
.user-photo-preview.active { display: block; }

/* ══════════════════════════════════
   JOURNAL / SCRAPBOOK MODE
══════════════════════════════════ */
#lid-container[data-view="journal"] {
    max-width: 560px;
    margin: 0 auto;
    padding: 20px 14px 40px;
    display: flex;
    flex-direction: column;
    gap: 0;
    /* matches app background — no custom paper colour */
    background: transparent;
}

/* Card shell — matches lid card aesthetic */
.lid-card.journal-mode {
    display: flex;
    flex-direction: column;
    min-width: 0;  /* allow grid cells to shrink correctly */
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
    gap: 0;
    align-items: stretch;
    transform: none;    /* no wonky rotation — clean and professional */
    margin-top: 0;
}
body.dark-mode .lid-card.journal-mode {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.journal-header-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) 56px var(--space-4) var(--space-4);
    background: var(--poke-red);
    position: relative;
    min-height: 110px;
}

/* Lid — clean circle, no box, no stamp */
.journal-lid-img {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    object-fit: contain;
    flex-shrink: 0;
    cursor: pointer;
    display: block;
    border: 3px solid rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.08);
}

/* Info — left-aligned next to lid */
.journal-info-strip {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.journal-pref-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.journal-pref-tag {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #ffffff;
    background: rgba(255,255,255,0.10);
    border: 1.5px solid rgba(255,255,255,0.38);
    border-radius: 50px;
    padding: 2px 10px;
}
.journal-la-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--la-badge-text);
    background: var(--la-badge-bg);
    border: 1.5px solid var(--la-badge-border);
    border-radius: 50px;
    padding: 2px 10px;
    white-space: nowrap;
}
.journal-city {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.journal-poke-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.3;
    word-break: break-word;
}

/* Share btn — top-right of header */
.journal-header-actions {
    position: absolute;
    top: 12px; right: 12px;
}
.j-btn-share {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: 50%;
    width: 44px; height: 44px;
    font-size: 0.76rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: white;
    transition: background 0.15s;
}
.j-btn-share:active { background: rgba(255,255,255,0.32); }

/* Date and details actions stay together under the visit header. */
.journal-datebar {
    display: flex;
    align-items: center;
    padding: 7px 14px 7px;
    background: var(--surface);
    border-bottom: 1px solid var(--divider);
}
body.dark-mode .journal-datebar { background: var(--surface); border-bottom-color: var(--divider); }
.journal-datebar::before {
    content: none;
}
.jdate-cal-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: #9a4040;
    font-size: 0.78rem;
    flex-shrink: 0;
    min-height: 44px;
}
body.dark-mode .jdate-cal-btn { color: #c07070; }
.jdate-cal-btn:hover, .jdate-cal-btn:active { color: var(--poke-red); }
.catch-date-label {
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: #8a3030;
}
body.dark-mode .catch-date-label { color: #c07070; }

/* ══ PHOTO: full width, natural height ══ */
.journal-photo-wrap {
    position: relative;
    background: #e8e4de;
    width: 100%;
    line-height: 0;
    cursor: pointer;
}
body.dark-mode .journal-photo-wrap { background: #2a2a38; }
.journal-photo-main {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}
.journal-photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 28px 0;
    background: rgba(229,57,53,0.04);
    border-top: 1px dashed rgba(180,60,60,0.18);
    border-bottom: 1px dashed rgba(180,60,60,0.18);
    cursor: pointer;
}
body.dark-mode .journal-photo-placeholder { background: rgba(255,255,255,0.03); }
.jph-label {
    font-size: 0.78rem;
    color: #785454;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
}
.j-btn-cam {
    position: absolute;
    bottom: 7px; right: 7px;
    z-index: 5;
    background: rgba(255,255,255,0.88);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 50%;
    width: 44px; height: 44px;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 5px rgba(0,0,0,0.13);
}
.j-btn-cam:active { background: rgba(255,255,255,1); }

/* ══ NOTE: Nunito, centred, grows with content ══ */
.journal-note-display {
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.55;
    padding: var(--space-3) var(--space-4);
    text-align: center;
    background: var(--surface);
    border-top: 1px solid var(--divider);
    cursor: pointer;
    word-break: break-word;
}
body.dark-mode .journal-note-display { background: var(--surface); color: var(--text); }
.journal-note-display.journal-note-empty {
    font-style: normal;
    font-size: 0.76rem;
    color: var(--text-muted);
    padding: var(--space-3) var(--space-4);
    font-weight: 600;
    letter-spacing: 0.1px;
}
body.dark-mode .journal-note-display.journal-note-empty { color: #c8ccd4; }

/* Textarea for editing */
.poke-note-input {
    display: none;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: none;
    border-top: 1px solid var(--divider);
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--text);
    resize: none;
    min-height: 54px;
    text-align: center;
    line-height: 1.55;
    box-sizing: border-box;
}
.poke-note-input.show { display: block; }
.poke-note-input:focus { outline: none; }
.poke-note-input:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; }

/* ══ Catch the j-btn-note (hidden — note display is tap target) ══ */
.j-btn-note { display: none; }

/* ══════════════════════════════════
   SETTINGS PANEL
══════════════════════════════════ */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 6000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.settings-overlay.open { display: flex; }

.settings-sheet {
    background: var(--surface);
    width: 100%;
    max-width: 480px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 0 0 40px;
    box-shadow: var(--shadow-md);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
}
.settings-storage-note { margin: var(--space-1) var(--space-5) var(--space-4); color: var(--text-muted); font-size: 0.8rem; line-height: 1.5; }
.settings-storage-note.storage-warning { padding: 12px; border: 1px solid currentColor; border-radius: var(--radius-md); color: var(--text); }
.settings-handle {
    width: 44px; height: 5px;
    background: #ddd;
    border-radius: 3px;
    margin: 14px auto 0;
}
.settings-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    padding: var(--space-4) var(--space-5) var(--space-3);
    color: var(--text);
    border-bottom: 1px solid var(--divider);
}
.settings-items { padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-5); }
.settings-group { display: flex; flex-direction: column; gap: var(--space-3); }
.settings-group-title { margin: 0; color: var(--text-muted); font-size: 0.75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.settings-group .settings-storage-note { margin: 0 var(--space-1); }
.settings-group + .settings-group { padding-top: var(--space-4); border-top: 1px solid var(--divider); }

.settings-btn {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-subtle);
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    text-align: left;
    text-decoration: none;
    transition: var(--transition);
    width: 100%;
}
.settings-btn:hover, .settings-btn:active { background: var(--action-soft); border-color: var(--poke-red); }
.settings-btn .s-icon {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.settings-btn .s-text { flex: 1; }
.settings-btn .s-text small { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.75rem; margin-top: var(--space-1); line-height: 1.4; }

.s-export .s-icon  { background: #e3f2fd; }
.s-import .s-icon  { background: #e8f5e9; }
.s-journal .s-icon { background: #fff8e1; }
.s-map .s-icon     { background: #f3e5f5; }
.s-reset .s-icon   { background: #ffebee; }
.s-reset { border-color: #ffcdd2; }
.s-reset .s-text   { color: #c62828; }
.s-about .s-icon { color: var(--text-muted); background: var(--surface); font-weight: 800; }
.settings-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-4); margin: 0 var(--space-5) var(--space-2); }
.settings-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-muted); font-size: 0.8rem; text-underline-offset: 3px; }
.settings-links a:hover { color: var(--text); }

.settings-close {
    display: block;
    margin: var(--space-1) var(--space-5) 0;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    width: calc(100% - var(--space-5) * 2);
    text-align: center;
}

/* ══════════════════════════════════
   BOTTOM STATS BAR
══════════════════════════════════ */
.save-menu {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--save-menu-bg);
    padding: 10px 16px 18px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    border-top: 3px solid var(--poke-dark);
    z-index: 1000;
    box-shadow: 0 -1px 4px rgba(0,0,0,var(--save-menu-shadow-opacity));
}
#bottom-stats-container { max-width: 1200px; margin: 0 auto; }
.progress-stat { min-width: 0; }
.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
    color: var(--poke-dark);
}
.stats-row .count { color: #b52724; }
.bar-container {
    width: 100%;
    background: #eee;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}
.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}
.bar-fill.total { background: var(--poke-red); }
.bar-fill.pref  { background: var(--poke-green); }

/* ══════════════════════════════════
   MAP
══════════════════════════════════ */
body.map-active {
    padding-bottom: 0;
}

#map-container {
    /* Height set dynamically by setMapHeight() in app.js */
    position: relative;
    height: 400px;
    flex-shrink: 0;
}
#map {
    height: 100%;
    width: 100%;
}
.map-empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-6);
    box-shadow: var(--shadow-md);
    z-index: 500;
    pointer-events: none;
}
.map-empty-icon { font-size: 2.5rem; margin-bottom: 8px; }
.map-empty-state p { font-weight: 700; color: var(--text); font-size: 0.95rem; }
body.dark-mode .map-empty-state { background: var(--surface); }
body.dark-mode .map-empty-state p { color: var(--text); }
.custom-marker {
    border: 2px solid white;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    cursor: pointer;
}

/* ══════════════════════════════════
   EMPTY STATE
══════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 60px 30px;
    color: #626978;
    grid-column: 1 / -1;
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 10px; }
.empty-state p { font-size: 0.9rem; font-weight: 600; }

/* ══════════════════════════════════
   DARK MODE
══════════════════════════════════ */
body.dark-mode {
    --canvas: #1b1d29;
    --surface: #242735;
    --surface-subtle: #2d3040;
    --text: #f2f4f8;
    --text-muted: #c5cbd7;
    --border: #555b70;
    --caught-surface: #24352b;
    --action-soft: #3a2836;
    --save-menu-bg: var(--surface);
    --save-menu-shadow-opacity: 0.12;
    background: var(--canvas);
    color: var(--text);
    --focus-ring: #8ac8ff;
}
body.dark-mode .collection-tagline, body.dark-mode #results-summary, body.dark-mode .catch-filter-field label, body.dark-mode .settings-storage-note { color: var(--text-muted); }
body.dark-mode #catch-filter, body.dark-mode .filter-reset-btn, body.dark-mode .app-status { background: var(--surface); color: var(--text); border-color: var(--border); }
body.dark-mode .filter-reset-btn:hover, body.dark-mode .filter-reset-btn:active { background: var(--action-soft); border-color: #ffaaa2; }
body.dark-mode .lid-card {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
body.dark-mode .lid-card.is-caught-card {
    background: var(--caught-surface);
}
body.dark-mode .city-label { color: var(--text); }
body.dark-mode .pref-tag, body.dark-mode .stats-row .count { color: #ff8a80; }
body.dark-mode .poke-name  { color: var(--text-muted); }
body.dark-mode .lid-img    { background: var(--surface-subtle); border-color: var(--border); }
body.dark-mode .lid-card.is-caught-card .lid-img { border-color: var(--poke-green); }
body.dark-mode .mini-btn   { background: var(--surface-subtle); color: var(--text-muted); }
body.dark-mode .mini-btn:hover, body.dark-mode .mini-btn:active { background: var(--action-soft); color: var(--text); }
body.dark-mode .poke-note-input { background: var(--surface); border-color: var(--border); color: var(--text); }
/* Pokeball always looks like a pokeball — keep light-mode colors in dark mode */
body.dark-mode .catch-btn  { border-color: #1a1a2a; background: white; }
body.dark-mode .catch-btn::before { background: #ddd; }
body.dark-mode .catch-btn::after  { background: white; border-color: #1a1a2a; }
body.dark-mode .catch-btn .pb-line { background: #1a1a2a; }
body.dark-mode .catch-btn.is-caught { border-color: var(--poke-dark); }
body.dark-mode .catch-btn.is-caught::before { background: var(--poke-red); }
body.dark-mode .catch-btn.is-caught::after  { background: white; border-color: var(--poke-dark); }
body.dark-mode .catch-btn.is-caught .pb-line { background: var(--poke-dark); }
body.dark-mode .catch-label { color: #b4bac7; }
body.dark-mode .catch-btn.is-caught + .catch-label { color: #81c784; }
body.dark-mode .save-menu   { border-top-color: #333; }
html:has(body.dark-mode) { background: #1b1d29; }
body.dark-mode .stats-row   { color: #ccc; }
body.dark-mode .bar-container { background: #2a2a38; }


body.dark-mode .journal-stamp          { background: rgba(30,30,42,0.95); }



body.dark-mode .settings-sheet        { background: var(--surface); }
body.dark-mode .settings-title        { color: var(--text); border-bottom-color: var(--divider); }
body.dark-mode .settings-btn          { background: var(--surface-subtle); border-color: var(--border); color: var(--text); }
body.dark-mode .settings-btn:hover, body.dark-mode .settings-btn:active { background: var(--action-soft); border-color: #ffaaa2; }
body.dark-mode .settings-btn .s-text small { color: var(--text-muted); }
body.dark-mode .settings-close        { background: var(--surface); border-color: var(--border); color: var(--text); }
body.dark-mode .settings-handle       { background: #444; }
body.dark-mode .s-reset .s-text       { color: #ef9a9a; }
body.dark-mode .s-reset               { border-color: #5a2020; }
body.dark-mode .user-photo-preview    { border-color: var(--border); }
body.dark-mode #pref-nav              { background: #1a1a28; }
body.dark-mode .empty-state           { color: #c8ccd4; }

/* Dark mode toggle (used inside settings sheet) */
.dark-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-subtle);
    margin-bottom: 0;
}
body.dark-mode .dark-toggle-row { background: var(--surface-subtle); border-color: var(--border); }
.dark-toggle-left { display: flex; align-items: center; gap: 12px; }
.dark-toggle-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.dark-toggle-label { font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 0.9rem; color: var(--poke-dark); }
body.dark-mode .dark-toggle-label { color: #eee; }
.dark-toggle-sub { display: block; font-weight: 400; color: #626978; font-size: 0.72rem; margin-top: 1px; }
body.dark-mode .dark-toggle-sub, body.dark-mode .jph-label { color: #b4bac7; }
.dark-toggle-track {
    width: 52px; height: 44px;
    border-radius: 22px;
    background: #ccc;
    position: relative;
    transition: background 0.25s;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}
.dark-toggle-track.on { background: var(--poke-red); }
.dark-toggle-thumb {
    position: absolute;
    top: 8px; left: 5px;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: white;
    transition: transform 0.25s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.dark-toggle-track.on .dark-toggle-thumb { transform: translateX(14px); }

/* ══════════════════════════════════
   SHARE CARD MODAL
══════════════════════════════════ */
.share-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 7000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.share-overlay.open { display: flex; }
.share-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 340px;
    max-height: 90vh;
    max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-md);
}
body.dark-mode .share-modal { background: var(--surface); }
.share-modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--poke-red);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.share-modal-header h2 { font-family: 'Fredoka', sans-serif; font-size: 1.1rem; font-weight: 700; color: white; margin: 0; }
.share-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    width: 44px; height: 44px;
    flex-shrink: 0;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
#share-canvas-wrap {
    padding: 16px;
    display: flex;
    justify-content: center;
    background: #f8f8f8;
    position: relative;
}
body.dark-mode #share-canvas-wrap { background: #151520; }
#share-canvas { border-radius: var(--radius-md); box-shadow: var(--shadow-sm); max-width: 100%; height: auto !important; }
#share-canvas-wrap[data-format="story"] #share-canvas { max-width: min(100%, max(150px, calc((100dvh - 410px) * 0.5625))); }
.share-format-field { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
.share-format-field label { color: var(--text-muted); font-size: 0.75rem; font-weight: 800; }
#share-format { width: 100%; min-width: 0; min-height: 44px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 700 0.85rem 'Nunito', sans-serif; cursor: pointer; }
#share-format-details { color: var(--text-muted); font-size: 0.75rem; line-height: 1.5; }
.share-preparation-status { padding: var(--space-3) var(--space-4) 0; color: var(--text-muted); font-size: 0.8rem; line-height: 1.5; overflow-wrap: anywhere; }
.share-actions { padding: var(--space-3) var(--space-4); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.share-actions button { min-width: 0; min-height: 44px; padding-left: var(--space-2); padding-right: var(--space-2); }
.share-customize { margin: 0 var(--space-4) var(--space-4); border-top: 1px solid var(--divider); }
.share-customize summary { cursor: pointer; min-height: 44px; padding: 12px 0; font-weight: 800; color: var(--text); }
.share-customize-fields { display: grid; gap: var(--space-2); }
.share-customize-fields > label { font-size: 0.8rem; font-weight: 800; color: var(--text); }
.share-customize-fields select, .share-customize-fields textarea { width: 100%; min-width: 0; min-height: 44px; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 600 0.85rem 'Nunito', sans-serif; }
.share-customize-fields textarea { resize: vertical; }
.share-check { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; cursor: pointer; }
.share-check input { width: 20px; height: 20px; accent-color: var(--poke-red); }
.share-field-hint { font-size: 0.75rem; line-height: 1.5; color: var(--text-muted); overflow-wrap: anywhere; }
.share-caption-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.share-caption-actions button { min-height: 44px; padding: var(--space-2); }
.btn-primary {
    flex: 1;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    border: none;
    background: var(--poke-red);
    color: white;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition);
}
.btn-primary:hover, .btn-primary:active { background: var(--action-hover); }
.btn-secondary {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    color: var(--text-muted);
}
body.dark-mode .btn-secondary { background: var(--surface-subtle); border-color: var(--border); color: var(--text); }
.btn-secondary:hover, .btn-secondary:active { background: var(--action-soft); border-color: var(--poke-red); }
.share-actions button:disabled { border: 1px solid var(--border); background: var(--surface-subtle); color: var(--text-muted); cursor: default; }

/* ══════════════════════════════════
   ADJUST PANEL (zoom + pan)
══════════════════════════════════ */
#crop-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    cursor: grab;
    border-radius: 16px;
    touch-action: none;
    user-select: none;
}
#crop-overlay:active { cursor: grabbing; }
#crop-panel {
    padding: var(--space-3) var(--space-4) var(--space-4);
    border-top: 1px solid var(--divider);
}
body.dark-mode #crop-panel { border-top-color: var(--divider); }
.crop-panel-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: var(--space-2);
    line-height: 1.5;
    font-family: 'Nunito', sans-serif;
}
.crop-zoom-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
}
.crop-zoom-icon { font-size: 1rem; }
.crop-zoom-row input[type="range"] {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    accent-color: var(--poke-red);
    cursor: pointer;
}
.crop-nudge-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.crop-frame-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.crop-frame-controls button { min-width: 0; min-height: 44px; padding: var(--space-2); font-size: 0.8rem; }
.crop-nudge-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-width: 0; min-height: 44px; padding: var(--space-2); font-size: 0.8rem; }
.crop-nudge-btn > span { font-size: 1rem; }
.crop-panel-actions {
    display: flex;
    gap: 8px;
    padding: var(--space-3) 0 0;
}
.crop-panel-actions button { min-width: 0; min-height: 44px; }

/* ══════════════════════════════════
   CATCH DATE ROW (on cards)
══════════════════════════════════ */
.catch-date-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #f0f0f0;
}
body.dark-mode .catch-date-row { border-top-color: #2a2a38; }

.catch-date-label {
    font-size: 0.7rem;
    color: #626978;
    font-weight: 600;
}
body.dark-mode .catch-date-label { color: #c8ccd4; }

.catch-date-edit-btn {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--poke-red);
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: 0.15s;
}
.catch-date-edit-btn:hover { background: #fff0f0; }
body.dark-mode .catch-date-edit-btn:hover { background: #2a1a1a; }

/* ══════════════════════════════════
   DATE PICKER MODAL
══════════════════════════════════ */
.date-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 7500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.date-overlay.open { display: flex; }

.date-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 320px;
    max-height: calc(100dvh - var(--space-5) * 2);
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}
body.dark-mode .date-modal { background: var(--surface); }

.date-modal-header {
    background: var(--poke-red);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.date-modal-header h2 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

.date-modal-body { padding: 18px; }

.date-hint {
    font-size: 0.78rem;
    color: #626978;
    margin-bottom: 14px;
    line-height: 1.5;
}
body.dark-mode .date-hint { color: #b4bac7; }

.date-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid var(--border);
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--poke-dark);
    background: #fafafa;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 12px;
}
.date-input:focus { border-color: var(--poke-red); }
body.dark-mode .date-input {
    background: #2a2a38;
    border-color: var(--border);
    color: #eee;
    color-scheme: dark;
}

.date-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}
.date-preset-btn {
    padding: 8px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: #fafafa;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    color: #555;
    cursor: pointer;
    transition: 0.15s;
    min-height: 44px;
}
.date-preset-btn:hover { border-color: var(--poke-red); color: var(--poke-red); background: #fff0f0; }
.date-preset-btn:active { background: var(--action-soft); }
body.dark-mode .date-preset-btn { background: #2a2a38; border-color: var(--border); color: #aaa; }
body.dark-mode .date-preset-btn:hover { border-color: var(--poke-red); color: #ff8a80; background: #2a1a1a; }

.date-modal-actions {
    padding: 0 16px 16px;
    display: flex;
    gap: 8px;
}

/* ══════════════════════════════════
   POKÉMON LOCAL ACTS BADGE
══════════════════════════════════ */
.la-badge {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--la-badge-text);
    background: var(--la-badge-bg);
    border: 1px solid var(--la-badge-border);
    border-radius: 50px;
    padding: 1px 8px;
    vertical-align: middle;
    margin-left: 4px;
    white-space: nowrap;
}
.la-mascot {
    font-size: 0.75rem;
    vertical-align: middle;
    margin-left: 3px;
    cursor: default;
}

/* ── LOCAL ACTS BANNER CARD ── */
.la-banner-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    position: relative;
    margin-bottom: var(--space-3);
}
.la-banner-img {
    width: 100%;
    display: block;
    height: auto;
    aspect-ratio: 10 / 3;
}
.la-banner-footer {
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border-top: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}
.la-banner-copy { display: grid; gap: 2px; min-width: 0; }
.la-banner-mascot { color: var(--text-muted); font-size: 0.75rem; line-height: 1.4; }
.la-banner-label {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.la-banner-hint {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
}

/* ── MASCOT LIGHTBOX ── */
.mascot-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.mascot-lightbox.open { display: flex; }
.mascot-lightbox-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.mascot-lightbox-inner img {
    width: min(72vw, 280px);
    height: auto;
    display: block;
}

/* ══════════════════════════════════
   LID LIGHTBOX
══════════════════════════════════ */
.lid-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.lid-lightbox.open { display: flex; }

.lid-lightbox-close {
    position: absolute;
    top: max(18px, env(safe-area-inset-top));
    right: 18px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    border: 1.5px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 1;
}
.lid-lightbox-close:active { background: rgba(255,255,255,0.32); }

.lid-lightbox-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#lid-lightbox-img {
    width: min(76vw, 320px);
    height: min(76vw, 320px);
    border-radius: 50%;
    object-fit: contain;
    background: rgba(255,255,255,0.08);
    border: 4px solid rgba(255,255,255,0.7);
    display: block;
}

.lid-lightbox-info {
    text-align: center;
}
.lid-lightbox-city {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: white;
    line-height: 1.1;
}
.lid-lightbox-sub {
    font-size: 0.88rem;
    color: #d5d9e1;
    margin-top: 4px;
    letter-spacing: 0.3px;
}

/* ══════════════════════════════════
   BACK TO TOP BUTTON
══════════════════════════════════ */
.back-to-top {
    position: fixed;
    bottom: calc(110px + env(safe-area-inset-bottom));
    right: 16px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--poke-dark);
    color: white;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm);
    z-index: 1500;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-to-top:active { transform: scale(0.9); }
body.dark-mode .back-to-top { background: #f0f2f5; color: var(--poke-dark); }
/* ══════════════════════════════════════════════
   DESKTOP LAYOUT  (768px+)
══════════════════════════════════════════════ */
@media (min-width: 768px) {

    body { background: var(--canvas); padding-bottom: 80px; }

    /* ── HEADER ── */
    .nav-sticky-wrapper { overflow: visible; }
    .header-inner {
        max-width: calc(var(--desktop-content-width) - var(--space-5) * 2);
        margin: 0 auto;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) 44px;
        align-items: center;
        gap: 16px;
    }
    .header-top, .header-actions { display: contents; }
    .header-title { grid-column: 1; grid-row: 1; font-size: 1.75rem; white-space: nowrap; }
    .header-title span { width: 24px; height: 24px; margin-right: 8px; }
    .search-field { grid-column: 1 / -1; grid-row: 2; }
    #poke-search { width: 100%; font-size: 1rem; padding: 11px 18px; }
    .header-view-btns { grid-column: 2; grid-row: 1; margin-top: 0; gap: 8px; justify-content: flex-end; }
    .view-btn { flex: none; padding: 8px 20px; font-size: 0.82rem; border-radius: 12px; }
    .settings-tab-btn { position: static; grid-column: 3; grid-row: 1; }

    /* ── NAV ── */
    .nav-desktop-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
    .region-nav-row { display: flex; align-items: center; }
    #region-nav {
        flex: 1;
        flex-wrap: wrap;
        overflow-x: visible;
        padding: 10px 0;
        gap: 6px;
    }
    #region-nav button { font-size: 0.8rem; padding: 7px 16px; }
    #pref-nav {
        flex-wrap: wrap;
        overflow-x: visible;
        padding: 8px 0;
        gap: 6px;
    }
    #pref-nav button { font-size: 0.78rem; padding: 5px 14px; }

    /* ── GEAR BUTTON IN NAV ── */
    .nav-gear-wrap { display: block; position: relative; flex-shrink: 0; padding: 0 4px 0 12px; }
    .nav-gear-btn {
        width: 34px; height: 34px;
        border-radius: 50%;
        border: 2px solid rgba(255,255,255,0.25);
        background: rgba(255,255,255,0.1);
        color: white;
        font-size: 1rem;
        cursor: pointer;
        display: flex; align-items: center; justify-content: center;
        transition: background 0.15s;
    }
    .nav-gear-btn:hover { background: rgba(255,255,255,0.22); }

    /* ── MAIN CONTENT ── */
    .main-desktop-inner {
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px 24px;
    }
    .collection-toolbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        padding: var(--space-4) var(--space-5) 0;
        gap: var(--space-3) var(--space-4);
    }
    .collection-heading-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2) var(--space-4); }
    .collection-heading-row #results-summary { margin-top: 0; }
    .collection-filters { gap: var(--space-2); }
    .collection-filters .catch-filter-field { gap: var(--space-1); }
    .collection-filters #catch-filter { min-width: 140px; }
    .collection-filters #collection-sort { min-width: 148px; }
    .setup-status { padding: 0 24px; }

    /* Map goes full viewport width */
    #map-container {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
        height: calc(100vh - 200px);
    }

    /* ── CARD GRID: 2 columns ── */
    #lid-container {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 20px 24px;
        max-width: 1400px;
        margin: 0 auto;
        box-sizing: border-box;
    }

    /* ── JOURNAL: 2 columns on desktop ── */
    #lid-container[data-view="journal"] {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-width: 1400px;
        margin: 0 auto;
        padding: 20px 24px;
        gap: 20px;
    }
    .la-banner-label { font-size: 1.15rem; }
    .lid-card:not(.journal-mode) { --lid-art-size: 120px; --lid-inset: 12px; --catch-size: 80px; }
    .city-label { font-size: 1.25rem; }

    /* ── STATS BAR ── */
    .save-menu {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        padding: 10px 40px 14px;
        z-index: 1000;
    }
    #bottom-stats-container { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
    .progress-stat .bar-container { margin-bottom: 0; }
    .save-menu-inner {
        max-width: 1200px;
        margin: 0 auto;
        display: grid;
        grid-template-columns: 1fr 1fr auto;
        gap: 0 24px;
        align-items: center;
        position: relative;
    }

    /* Gear button */
    .dsd-gear-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border-radius: 50%;
        border: 2px solid rgba(0,0,0,0.1);
        background: white;
        font-size: 1.1rem;
        cursor: pointer;
        flex-shrink: 0;
        box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    }
    .dsd-gear-btn:hover { background: #f5f5f5; }

    /* ── SETTINGS: centred modal, not bottom sheet ── */
    .settings-overlay,
    .settings-overlay.open {
        align-items: center;
        justify-content: center;
    }
    .settings-sheet {
        width: 440px;
        max-width: 90vw !important;
        max-height: 88vh;
        overflow-y: auto;
        border-radius: var(--radius-lg) !important;
        padding: 0 0 20px !important;
        box-shadow: var(--shadow-md) !important;
    }
    .settings-handle { display: none; }

    /* Preserve the complete Local Acts artwork rather than cropping the mascot. */
    .la-banner-card { grid-column: 1 / -1; height: auto; margin-bottom: 0; }
}

/* ══════════════════════════════════════════════
   DESKTOP MAP-ACTIVE: compact geography for taller map
══════════════════════════════════════════════ */
@media (min-width: 768px) {
    body.map-active #region-nav    { padding: 5px 0; }
    body.map-active #pref-nav      { padding: 5px 0; }
}

/* ── Single-row header when search and all views comfortably fit ── */
@media (min-width: 960px) {
    .view-btn { padding-left: 14px; padding-right: 14px; }
    .header-inner { grid-template-columns: auto minmax(0, 1fr) auto 44px; }
    .search-field { grid-column: 2; grid-row: 1; }
    .header-view-btns { grid-column: 3; grid-row: 1; }
    .settings-tab-btn { grid-column: 4; }
}

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 80px);
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: rgba(0,0,0,0.82);
    color: #fff;
    padding: 10px 22px;
    border-radius: 20px;
    font-size: 0.9rem;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    white-space: normal;
    width: max-content;
    max-width: min(90vw, 560px);
    overflow-wrap: anywhere;
    text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(211,47,47,0.92); }

/* ── MAP MARKERS ── */
.map-marker {
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #aaa;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    background: white;
}
.map-marker.caught {
    border: 2.5px solid #43a047;
    box-shadow: 0 0 0 2px rgba(67,160,71,0.3), 0 2px 8px rgba(0,0,0,0.3);
}
.map-marker img { width: 100%; height: 100%; object-fit: contain; }
.map-marker img.uncaught { filter: grayscale(80%) opacity(0.55); }

/* ── MARKER CLUSTER OVERRIDES ── */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(229, 57, 53, 0.25);
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background-color: rgba(229, 57, 53, 0.85);
    color: #fff;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
}

/* ── MAP POPUPS ── */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.map-popup { text-align: center; min-width: 120px; font-family: sans-serif; }
.map-popup-img {
    width: 64px; height: 64px;
    border-radius: 50%; object-fit: contain;
    border: 2px solid #eee; margin-bottom: 4px;
    display: block; margin-left: auto; margin-right: auto;
}
.map-popup-city { font-weight: 700; font-size: 0.95rem; margin-bottom: 2px; }
.map-popup-poke { color: var(--text-muted); font-size: 0.78rem; margin-bottom: var(--space-2); }
.map-popup-caught { color: #24652e; font-size: 0.72rem; font-weight: 700; margin-bottom: var(--space-2); }
body.dark-mode .map-popup-caught { color: #b7e4bd; }
.map-popup-link {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: var(--space-2) var(--space-3); margin-bottom: var(--space-2);
    background: var(--poke-red); color: white;
    border-radius: var(--radius-md); font-size: 0.8rem;
    font-weight: 700; text-decoration: none;
}
.leaflet-container a.map-popup-link { color: white; }
.map-popup-link:hover, .map-popup-link:active { background: var(--action-hover); }

.journal-note-empty-text { color: var(--text-muted); font-size: 0.9rem; }
#import-file { display: none; }

/* ── CONFIRM MODAL ── */
.confirm-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 5000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
.confirm-overlay.open { opacity: 1; pointer-events: auto; }
.confirm-modal {
    background: var(--surface, #fff);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    max-width: 320px; width: 90%;
    box-shadow: var(--shadow-md);
}
.confirm-message { font-size: 1rem; margin-bottom: 20px; text-align: center; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-btn-cancel {
    padding: 8px 18px; border-radius: 8px;
    border: 1px solid var(--border); background: transparent;
    cursor: pointer; font-size: 0.9rem;
    min-height: 44px;
}
.confirm-btn-ok {
    padding: 8px 18px; border-radius: 8px;
    border: none; background: #e53935; color: #fff;
    cursor: pointer; font-size: 0.9rem; font-weight: 700;
    min-height: 44px;
}
body.dark-mode .confirm-modal { background: var(--surface, #1e1e1e); color: var(--text, #eee); }
body.dark-mode .confirm-btn-cancel { border-color: var(--border); color: #eee; }

/* A service worker update waits until the user chooses to reload. */
.update-notice {
    position: fixed;
    bottom: calc(110px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: min(480px, calc(100% - 24px));
    z-index: 3500;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: white;
    color: var(--poke-dark);
    border: 2px solid var(--poke-red);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
}
.update-notice p { flex: 1; min-width: 0; font-size: 0.85rem; line-height: 1.4; }
.update-notice button { min-height: 44px; flex-shrink: 0; padding: 9px 14px; border: 0; border-radius: 10px; background: var(--poke-red); color: white; font: 800 0.85rem 'Nunito', sans-serif; cursor: pointer; }
body.dark-mode .update-notice { background: #28283e; color: #f0f2f5; }

@media (max-width: 374px) {
    .modern-header { padding-left: 12px; padding-right: 12px; }
    .header-title { font-size: 1.35rem; }
    .collection-toolbar { gap: 12px; }
    .collection-filters { width: 100%; }
    .catch-filter-field { flex: 1; min-width: 0; }
    #catch-filter { width: 100%; min-width: 0; }
    .lid-card:not(.journal-mode) { --lid-art-size: 80px; --lid-inset: 8px; --catch-size: 56px; }
    .catch-col { padding-right: 8px; }
    .journal-header-row { gap: 10px; padding: 14px 58px 14px 12px; }
    .journal-lid-img { width: 64px; height: 64px; }
    .journal-pref-row { flex-wrap: wrap; }
    .journal-city { font-size: 1.15rem; }
    .la-banner-label { font-size: 0.85rem; }
    .la-banner-hint { font-size: 0.6rem; }
}

.view-btn { background: rgba(0,0,0,0.12); }
.view-btn:hover { background: rgba(0,0,0,0.24); }
.view-btn.active, .view-btn:active { background: white; color: #9f1d1a; }
.settings-close { color: var(--text-muted); }
.crop-panel-hint { color: #626978; }
body.dark-mode .crop-panel-hint { color: #c8ccd4; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background: #b52724; }
.leaflet-control-attribution a { text-decoration: underline; }
#bottom-stats-container:not(.has-scope) { grid-template-columns: 1fr; }

@media (max-width: 767px) {
    .collection-toolbar { padding-top: 14px; gap: 10px; }
    .collection-copy { width: 100%; }
    #collection-heading { font-size: 1.25rem; }
    #results-summary { font-size: 0.75rem; margin-top: 4px; }
    .catch-filter-field label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
}

/* Shared travel controls and lid information. */
:root { --travel-surface: var(--surface); --travel-border: var(--border); --travel-muted: var(--text-muted); --mobile-dock-height: 64px; }
body.dark-mode { --travel-surface: var(--surface); --travel-border: var(--border); --travel-muted: var(--text-muted); }
.trip-nav-icon { width: 1.3em; height: 1.3em; vertical-align: -0.25em; }
.filters-toggle { display: none; }
.filters-sheet-header, .filters-sheet-footer, .filter-section-title { display: none; }
.pref-filter-section:has(#pref-nav:empty) { display: none; }
.filter-options { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 0 10px 10px; }
.filter-options .catch-filter-field label { color: #d8dce5; }
.filter-options #catch-filter { min-width: 180px; }
.sheet-close-btn { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border: 1px solid var(--travel-border); border-radius: 50%; background: var(--travel-surface); color: inherit; font-size: 1rem; cursor: pointer; }
.nearby-btn, .travel-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; padding: var(--space-3); border: 1px solid var(--travel-border); border-radius: var(--radius-md); background: var(--travel-surface); color: var(--text); font: 800 0.82rem 'Nunito', sans-serif; line-height: 1.35; text-align: center; text-decoration: none; cursor: pointer; transition: background var(--transition), border-color var(--transition); }
.nearby-btn { color: #9f2323; }
.trip-map-notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; max-width: 1400px; margin: 0 auto; padding: 12px 24px; background: var(--travel-surface); border-top: 1px solid var(--divider); color: var(--travel-muted); font-size: 0.85rem; line-height: 1.5; }
.trip-map-notice span { flex: 1; min-width: 180px; }
.nearby-btn:hover, .travel-btn:hover, .nearby-btn:active, .travel-btn:active { border-color: var(--poke-red); background: var(--action-soft); }
.nearby-btn:disabled, .travel-btn:disabled { opacity: 0.6; cursor: default; }
.travel-btn-primary { background: var(--poke-red); border-color: var(--poke-red); color: white; }
.travel-btn-primary:hover, .travel-btn-primary:active { background: var(--action-hover); color: white; }
.travel-btn-danger { color: #b52724; }
.travel-btn[aria-pressed="true"] { color: #24652e; background: #e9f5eb; border-color: #6b9e72; }
body.dark-mode .nearby-btn, body.dark-mode .travel-btn { color: var(--text); }
body.dark-mode .nearby-btn { color: #ffaaa2; }
body.dark-mode .nearby-btn:hover, body.dark-mode .travel-btn:hover, body.dark-mode .travel-btn:active { background: var(--action-soft); }
body.dark-mode .travel-btn-primary { background: #b52724; }
body.dark-mode .travel-btn-primary:hover, body.dark-mode .travel-btn-primary:active { background: var(--action-hover); }
body.dark-mode .travel-btn-danger { color: #ffaaa2; }
body.dark-mode .travel-btn[aria-pressed="true"] { background: #203c2a; color: #b7e4bd; }
#travel-container { max-width: 1400px; margin: 0 auto; }
.travel-layout { display: grid; gap: var(--space-4); padding: var(--space-3); }
.travel-section { min-width: 0; background: var(--travel-surface); border: 1px solid var(--travel-border); border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-sm); }
.travel-quick-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; grid-column: 1 / -1; }
.travel-edit-disclosure { margin: 12px 0; }
.travel-edit-disclosure summary { min-height: 44px; padding: 12px 0; cursor: pointer; color: var(--travel-muted); font-size: 0.85rem; font-weight: 800; }
.travel-edit-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.travel-edit-tools .travel-edit-disclosure { margin: 4px 0; min-width: 0; }
.travel-edit-tools .travel-edit-disclosure[open] { grid-column: 1 / -1; }
.lid-details-status.is-uncaught { background: var(--poke-grey); color: #565c6a; }
body.dark-mode .lid-details-status.is-uncaught { background: #333348; color: #c8ccd4; }
.travel-section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.travel-section-heading h2, h2.travel-section-heading { font: 700 1.25rem 'Fredoka', sans-serif; line-height: 1.25; }
.travel-description, .travel-meta, .travel-status { color: var(--travel-muted); font-size: 0.85rem; line-height: 1.5; overflow-wrap: anywhere; }
.travel-description { margin-top: 8px; }
.travel-description + .travel-btn { margin-top: 12px; }
.travel-meta { font-size: 0.78rem; }
.travel-status { margin-top: 10px; }
.travel-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 16px 0 10px; }
.travel-form label, .travel-trip-picker label, .lid-details-trip-form label { flex-basis: 100%; font-size: 0.8rem; font-weight: 800; }
.travel-input, .travel-trip-picker select, select.travel-trip-picker, .lid-details-trip-form select { min-height: 44px; min-width: 0; max-width: 100%; padding: var(--space-3); border: 1px solid var(--travel-border); border-radius: var(--radius-md); font: 600 1rem 'Nunito', sans-serif; background: var(--travel-surface); color: inherit; }
.travel-form .travel-input { flex: 1; min-width: 140px; }
.travel-trip-picker:not(select) { display: grid; gap: 6px; margin: 16px 0 10px; }
.travel-section > label { display: block; margin-top: 16px; font-size: 0.8rem; font-weight: 800; }
select.travel-trip-picker { margin: 6px 0 10px; }
.travel-trip-picker select, select.travel-trip-picker { width: 100%; }
.travel-trip-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 14px; }
.travel-trip-toolbar .travel-form { flex: 1; margin: 0; }
.travel-coordinate-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
.travel-coordinate-fields label { display: grid; gap: 5px; }
.travel-coordinate-fields .travel-input { width: 100%; min-width: 0; }
.travel-section > details { margin-top: 10px; }
.travel-section > details > summary { min-height: 44px; padding: 12px 0; font-size: 0.85rem; font-weight: 800; line-height: 1.4; cursor: pointer; }
.travel-section > details > .travel-form { margin-top: 6px; }
.travel-checkbox { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 10px; padding: 8px 0; font-size: 0.85rem; font-weight: 800; line-height: 1.4; cursor: pointer; }
.travel-checkbox input { flex-shrink: 0; width: 22px; height: 22px; accent-color: var(--poke-red); }
.travel-empty { margin-top: var(--space-4); padding: var(--space-5) var(--space-4); text-align: center; border: 1px dashed var(--travel-border); border-radius: var(--radius-md); color: var(--travel-muted); font-size: 0.9rem; line-height: 1.6; }
.travel-empty h3 { color: inherit; margin-bottom: 6px; }
.travel-list { display: grid; gap: var(--space-3); margin-top: var(--space-4); padding: 0; list-style: none; }
.travel-lid-row { position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: var(--space-3); align-items: center; min-width: 0; border: 1px solid var(--travel-border); border-radius: var(--radius-md); padding: var(--space-3); }
.travel-lid-row > .travel-empty { grid-column: 1 / -1; margin: 0; }
.travel-artwork { width: 64px; height: 64px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.travel-artwork img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: contain; }
.travel-lid-copy { min-width: 0; }
.travel-lid-copy h3 { font: 700 1rem 'Fredoka', sans-serif; line-height: 1.25; overflow-wrap: anywhere; }
.travel-lid-copy p { margin-top: 4px; font-size: 0.8rem; line-height: 1.45; color: var(--travel-muted); overflow-wrap: anywhere; }
.travel-row-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.travel-row-actions .travel-btn { flex: 1 0 auto; }
.travel-stop-number { position: absolute; left: 9px; top: 9px; z-index: 1; display: grid; place-items: center; width: 24px; height: 24px; background: var(--poke-red); color: white; border-radius: 8px; box-shadow: 0 0 0 2px var(--travel-surface); font-size: 0.75rem; font-weight: 800; pointer-events: none; }
.travel-reorder { display: flex; gap: 4px; }
.travel-reorder button { min-width: 44px; min-height: 44px; }
.lid-details-overlay { position: fixed; inset: 0; z-index: 8000; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); padding: var(--space-5); }
.lid-details-overlay.open { display: flex; }
.lid-details-sheet { background: var(--travel-surface); width: 560px; max-width: 100%; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.lid-details-header { position: sticky; top: 0; z-index: 2; display: flex; gap: var(--space-3); align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--divider); background: var(--travel-surface); }
.lid-details-header h2 { font: 700 1.3rem 'Fredoka', sans-serif; line-height: 1.25; }
#lid-details-content { padding: var(--space-5); }
.lid-details-hero { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 16px; align-items: center; }
.lid-details-artwork { display: block; width: 96px; height: 96px; padding: 0; object-fit: contain; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.lid-details-artwork img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.lid-details-hero h3 { font: 700 1.3rem 'Fredoka', sans-serif; line-height: 1.25; overflow-wrap: anywhere; }
.lid-details-hero p { margin-top: 5px; color: var(--travel-muted); font-size: 0.85rem; line-height: 1.5; }
.lid-details-status { display: inline-block; margin-top: 8px; padding: 5px 9px; border-radius: 8px; color: #24652e; background: #e9f5eb; font-size: 0.8rem; font-weight: 800; }
.lid-details-hero .lid-details-status { margin: 0; padding: 0; color: var(--travel-muted); background: transparent; font-weight: 600; }
#lid-detail-link { width: 100%; margin-top: 14px; }
.lid-details-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 20px; }
.lid-details-actions .travel-btn { width: 100%; }
.lid-details-trip-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 20px; }
.lid-details-trip-form select { flex: 1; min-width: 140px; }
.lid-details-note { margin-top: 20px; padding: 14px; border: 1px solid var(--travel-border); border-radius: 12px; color: var(--travel-muted); font-size: 0.9rem; line-height: 1.6; overflow-wrap: anywhere; }
.lid-details-footnote { margin-top: 16px; color: var(--travel-muted); font-size: 0.78rem; line-height: 1.5; }
body.dark-mode .lid-details-status { background: #203c2a; color: #b7e4bd; }
body.dark-mode .lid-details-hero .lid-details-status { color: var(--travel-muted); background: transparent; }
[role="dialog"][aria-hidden="false"], [role="alertdialog"][aria-hidden="false"] { z-index: 10000; }

@media (min-width: 768px) {
    html { scroll-padding-top: calc(var(--navigation-clearance, 140px) + 16px); }
    button, input, select, textarea, a, [tabindex] { scroll-margin-top: 16px; }
    .modern-header { position: sticky; top: 0; z-index: 2600; padding-top: calc(14px + env(safe-area-inset-top)); }
    body::before { background: var(--poke-red); }
    .nav-sticky-wrapper { position: relative; top: auto; background: var(--surface-subtle); border-bottom-color: var(--divider); }
    .nav-desktop-inner { max-width: var(--desktop-content-width); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); padding: var(--space-3) var(--space-5); }
    .geography-filters { display: grid; gap: var(--space-1); min-width: 0; }
    .region-filter-section, .pref-filter-section { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: start; gap: var(--space-3); min-width: 0; }
    .filter-section-title { display: flex; align-items: center; min-height: 44px; margin: 0; color: var(--text-muted); font-size: 0.75rem; font-weight: 800; }
    .pref-filter-section:has(#pref-nav:empty) { display: none; }
    .nav-desktop-inner #region-nav, .nav-desktop-inner #pref-nav { flex-wrap: wrap; gap: var(--space-1); min-width: 0; padding: 0; border: 0; background: transparent; }
    body.dark-mode .nav-desktop-inner #pref-nav { background: transparent; }
    .nav-desktop-inner #region-nav button, .nav-desktop-inner #pref-nav button { min-height: 44px; min-width: 44px; padding: var(--space-2); border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0; }
    .nav-desktop-inner #region-nav button:hover, .nav-desktop-inner #pref-nav button:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
    .nav-desktop-inner #region-nav button.active { background: var(--action-soft); border-color: #b52724; color: #9f2323; }
    .nav-desktop-inner #pref-nav button.active { background: var(--caught-surface); border-color: #287a32; color: #23622a; }
    body.dark-mode .nav-desktop-inner #region-nav button.active { color: #ffaaa2; border-color: #ed8079; }
    body.dark-mode .nav-desktop-inner #pref-nav button.active { color: #b7e4bd; border-color: #72b87b; }
    .nav-desktop-inner :focus-visible { outline-color: var(--focus-ring); }
    .filter-options { display: none; }
    .travel-layout { padding: var(--space-5); }
    .travel-section { padding: var(--space-5); }
    .travel-lid-row { grid-template-columns: 80px minmax(0, 1fr); }
    .travel-artwork { width: 80px; height: 80px; }
}

@media (min-width: 1100px) {
    .view-btn { padding-left: 14px; padding-right: 14px; }
    .travel-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .travel-section-planner { grid-column: 1 / -1; }
    .travel-section-planner .travel-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .collection-filters { flex-wrap: nowrap; }
}

@media (min-width: 1280px) {
    #lid-container { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 768px) and (max-width: 1099px) {
    .collection-toolbar { grid-template-columns: minmax(0, 1fr); }
}

/* The same four view buttons form a thumb-reachable dock on phones. */
@media (max-width: 767px) {
    html { scroll-padding-top: calc(120px + env(safe-area-inset-top)); scroll-padding-bottom: calc(128px + env(safe-area-inset-bottom)); }
    body { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }
    body::before { background: var(--poke-red); }
    .modern-header { position: sticky; top: 0; z-index: 2600; overflow: visible; padding: var(--space-2) var(--space-3) var(--space-3); padding-top: calc(var(--space-2) + env(safe-area-inset-top)); }
    .header-top { margin-bottom: 8px; }
    .header-title { font-size: 1.5rem; }
    .header-view-btns { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3500; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-1); width: 100%; height: calc(var(--mobile-dock-height) + env(safe-area-inset-bottom)); margin: 0; padding: 5px var(--space-2); padding-bottom: calc(5px + env(safe-area-inset-bottom)); border-top: 1px solid var(--divider); background: var(--travel-surface); box-shadow: var(--shadow-sm); }
    .view-btn { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: var(--space-1); min-width: 0; min-height: 50px; padding: var(--space-1) 2px; font-size: 0.72rem; line-height: 1.15; color: var(--text-muted); border: 0; border-radius: var(--radius-md); background: transparent; }
    .view-btn .pixel-icon, .view-btn .trip-nav-icon { width: 22px; height: 22px; }
    .view-btn.active, .view-btn:hover, .view-btn:active { background: var(--action-soft); color: #9f2323; }
    .modern-header .view-btn:focus-visible { outline-color: var(--focus-ring); outline-offset: -3px; }
    body.dark-mode .view-btn { color: var(--text-muted); }
    body.dark-mode .view-btn.active, body.dark-mode .view-btn:hover, body.dark-mode .view-btn:active { color: #ffaaa2; background: var(--action-soft); }
    .filters-toggle { display: inline-flex; gap: 5px; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 8px 10px; border: 1px solid rgba(255,255,255,0.6); border-radius: 12px; color: white; background: rgba(0,0,0,0.12); font: 800 0.8rem 'Nunito', sans-serif; cursor: pointer; }
    .filters-toggle > span:first-child { font-size: 1.2rem; }
    .filters-overlay { position: fixed; inset: 0; top: 0; z-index: 6500; display: none; align-items: flex-end; justify-content: center; background: rgba(0,0,0,0.55); box-shadow: none; }
    .filters-overlay.open { display: flex; }
    .filters-sheet { width: 100%; max-width: 560px; max-height: calc(100dvh - 20px - env(safe-area-inset-top)); overflow-y: auto; overscroll-behavior: contain; border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: var(--travel-surface); box-shadow: var(--shadow-md); }
    .filters-sheet-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); position: sticky; top: 0; z-index: 2; padding: var(--space-4); background: var(--travel-surface); border-bottom: 1px solid var(--divider); }
    .filters-sheet-header h2 { font: 700 1.25rem 'Fredoka', sans-serif; }
    .filters-sheet-header p { margin-top: 4px; color: var(--travel-muted); font-size: 0.8rem; line-height: 1.5; }
    .filter-section-title { display: block; margin: var(--space-4) var(--space-4) var(--space-2); font-size: 0.85rem; font-weight: 800; }
    .filters-sheet #region-nav, .filters-sheet #pref-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 var(--space-4); gap: var(--space-2); overflow: visible; background: transparent; border: 0; }
    .filters-sheet #region-nav button, .filters-sheet #pref-nav button { min-width: 0; white-space: normal; line-height: 1.35; padding: var(--space-3) var(--space-2); border: 1px solid var(--travel-border); border-radius: var(--radius-md); color: var(--text-muted); background: var(--surface-subtle); }
    .filters-sheet #region-nav button.active { color: white; background: var(--poke-red); border-color: var(--poke-red); }
    .filters-sheet #pref-nav button.active { color: white; background: #287a32; border-color: #287a32; }
    .filters-sheet :focus-visible { outline-color: var(--focus-ring); }
    .filter-options { padding: var(--space-4); gap: var(--space-3); }
    .filter-options .catch-filter-field { flex: 1; min-width: 0; }
    .filter-options .catch-filter-field label { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; color: var(--travel-muted); }
    .filter-options #catch-filter { width: 100%; min-width: 0; }
    .filters-sheet-footer { display: flex; position: sticky; bottom: 0; z-index: 2; padding: var(--space-3) var(--space-4); padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom)); background: var(--travel-surface); border-top: 1px solid var(--divider); }
    .filters-sheet-footer .btn-primary { min-height: 44px; }
    body.dark-mode .filters-sheet #region-nav button, body.dark-mode .filters-sheet #pref-nav button { background: var(--surface-subtle); color: var(--text); }
    body.dark-mode .filters-sheet #region-nav button.active { background: #b52724; color: white; }
    body.dark-mode .filters-sheet #pref-nav button.active { background: #287a32; color: white; }
    .collection-toolbar { align-items: center; padding: 14px 12px 4px; gap: 8px; }
    .collection-copy { flex: 1 1 100%; width: 100%; min-width: 0; }
    .collection-filters { width: 100%; gap: var(--space-2); flex-wrap: nowrap; }
    .collection-sort-field { flex: 1; }
    #collection-sort { min-width: 0; max-width: none; font-size: 1rem; }
    .collection-filters .nearby-btn { flex-shrink: 0; }
    .collection-scope-hint { font-size: 0.75rem; }
    .active-filter-chips { margin-top: var(--space-1); }
    .nearby-btn { padding: 9px 11px; font-size: 0.78rem; }
    .trip-map-notice { padding: 10px 12px; font-size: 0.8rem; }
    .trip-map-notice .filter-reset-btn { width: 100%; }
    .save-menu { bottom: calc(var(--mobile-dock-height) + env(safe-area-inset-bottom)); padding: 7px var(--space-3) 6px; border-top-width: 1px; box-shadow: var(--shadow-sm); }
    #bottom-stats-container { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
    .stats-row { font-size: 0.65rem; gap: 5px; }
    .stats-row > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .stats-row .count { flex-shrink: 0; }
    .progress-stat .bar-container { height: 5px; margin: 0; }
    .back-to-top, .toast, .update-notice { bottom: calc(var(--mobile-dock-height) + 60px + env(safe-area-inset-bottom)); }
    .travel-layout { gap: var(--space-3); padding-top: var(--space-3); }
    .travel-section { padding: var(--space-4); }
    .travel-section-heading h2, h2.travel-section-heading { font-size: 1.15rem; }
    .travel-lid-row { padding: var(--space-3); gap: var(--space-3); }
    .travel-row-actions .travel-btn { font-size: 0.76rem; padding-left: 9px; padding-right: 9px; }
    .lid-details-overlay { align-items: flex-end; padding: 0; }
    .lid-details-sheet { width: 100%; max-width: 560px; max-height: calc(100dvh - 20px - env(safe-area-inset-top)); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: env(safe-area-inset-bottom); }
    .lid-details-header { padding: var(--space-4); }
    #lid-details-content { padding: var(--space-4); }
    .lid-details-hero { grid-template-columns: 80px minmax(0, 1fr); gap: 12px; }
    .lid-details-artwork { width: 80px; height: 80px; }
    .lid-details-hero h3 { font-size: 1.2rem; }
}

@media (max-width: 1199px) {
    .journal-datebar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
    .journal-datebar::before { display: none; }
    .journal-datebar .jdate-cal-btn { margin-right: auto; }
}

@media (max-width: 374px) {
    .filter-toggle-text { display: none; }
    .header-top { gap: 8px; }
    .header-title { font-size: 1.25rem; }
    .collection-copy { min-width: 0; width: 100%; flex-basis: 100%; }
    .travel-artwork { width: 56px; height: 56px; }
    .travel-lid-row { grid-template-columns: 56px minmax(0, 1fr); }
    .travel-form .travel-input { min-width: 100px; }
    .lid-details-hero { grid-template-columns: 64px minmax(0, 1fr); }
    .lid-details-artwork { width: 64px; height: 64px; }
}

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

/* Compact collection header: one heading line, inline control labels and
   tighter geography rows leave more of the viewport for lids and the map. */
.collection-sort-field { display: flex; align-items: center; gap: var(--space-2); }
.collection-sort-field label { flex-shrink: 0; }
.collection-sort-field #collection-sort { flex: 1 1 auto; }
@media (max-width: 767px) {
    .collection-toolbar { padding-bottom: var(--space-2); }
    .collection-heading-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
    .collection-heading-row #collection-heading { flex-basis: 100%; }
    .collection-heading-row #results-summary { margin-top: 0; }
    .collection-heading-row .active-filter-chips { flex-basis: auto; margin-top: 0; }
    .collection-heading-row .active-filter-chip { min-height: 36px; padding: var(--space-1) var(--space-2); }
}
@media (max-width: 374px) {
    .collection-sort-field label { display: none; }
}
@media (min-width: 768px) {
    .nav-desktop-inner { padding-top: var(--space-2); padding-bottom: var(--space-2); }
    .geography-filters { gap: 2px; }
    .region-filter-section, .pref-filter-section { align-items: center; }
    .filter-section-title { min-height: 36px; }
    .nav-desktop-inner #region-nav button, .nav-desktop-inner #pref-nav button { min-height: 36px; padding: var(--space-1) var(--space-2); }

    .collection-toolbar { align-items: center; padding: var(--space-3) var(--space-5) 0; gap: var(--space-2) var(--space-4); }
    .collection-heading-row { align-items: center; row-gap: var(--space-1); }
    .collection-heading-row .active-filter-chips { flex-basis: auto; margin-top: 0; }
    .collection-heading-row .active-filter-chip { min-height: 32px; padding: var(--space-1) var(--space-2); }
    /* The geography bar already shows the active region and prefecture. */
    .active-filter-chip[data-filter="region"], .active-filter-chip[data-filter="prefecture"] { display: none; }
    .collection-tagline { margin-top: 2px; }
    .collection-filters { align-items: center; }
    .collection-filters .catch-filter-field { display: flex; align-items: center; gap: var(--space-2); }
    .collection-filters .catch-filter-field label, .collection-sort-field label { font-size: 0.75rem; }
    .collection-filters select, .collection-filters .nearby-btn, .collection-filters .filter-reset-btn { min-height: 40px; }

    .collection-toolbar { padding-bottom: var(--space-3); }
    body.map-active .nav-desktop-inner #region-nav, body.map-active .nav-desktop-inner #pref-nav { padding: 0; }
}

/* Geography hierarchy: regions are solid primary tabs; prefectures sit in a
   lighter tray beneath them so the two levels read differently. */
@media (min-width: 768px) {
    .nav-desktop-inner #region-nav button { padding: var(--space-1) var(--space-3); border-color: var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 0.82rem; }
    .nav-desktop-inner #region-nav button:hover { border-color: var(--poke-red); background: var(--action-soft); color: var(--text); }
    .nav-desktop-inner #region-nav button.active, body.dark-mode .nav-desktop-inner #region-nav button.active { border-color: #b52724; background: #b52724; color: #fff; }
    .nav-desktop-inner #region-nav button.active:hover { background: var(--action-hover); }

    .pref-filter-section { margin-top: var(--space-1); padding: 2px var(--space-2); border: 1px solid var(--border); border-left: 3px solid #b52724; border-radius: var(--radius-sm); background: var(--surface); }
    .pref-filter-section .filter-section-title { min-height: 32px; font-size: 0.7rem; }
    .nav-desktop-inner #pref-nav button { min-height: 32px; padding: 2px var(--space-2); border-radius: 999px; font-size: 0.76rem; font-weight: 600; }
    .nav-desktop-inner #pref-nav button:hover { background: var(--surface-subtle); }
    .nav-desktop-inner #pref-nav button.active { font-weight: 800; }
}

/* Lid cards: a firmer outline, hover feedback and evenly aligned text. */
:root { --card-border: #8f99ab; }
body.dark-mode { --card-border: #8792ae; }
.lid-card:not(.journal-mode), body.dark-mode .lid-card:not(.journal-mode) { border-color: var(--card-border); box-shadow: 0 1px 2px rgba(26,26,46,0.06), 0 3px 10px rgba(26,26,46,0.05); transition: background var(--transition), border-color var(--transition), box-shadow var(--transition); }
.lid-card.is-caught-card:not(.journal-mode) { border-color: var(--card-border); }
@media (hover: hover) {
    .lid-card:not(.journal-mode):hover { border-color: rgba(198,40,40,0.5); box-shadow: var(--shadow-md); }
    body.dark-mode .lid-card:not(.journal-mode):hover { border-color: #ed8079; }
}
.card-text { align-self: stretch; justify-content: center; }
.pref-tag { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); line-height: 1.3; }
.pref-tag .la-badge { margin-left: 0; padding: 2px 8px; line-height: 1.3; }
.card-actions { gap: 0; padding: 0; }
.card-actions .mini-btn { min-height: 44px; border-radius: 0; background: transparent; }
.card-actions .mini-btn + .mini-btn { border-left: 1px solid var(--divider); }
.card-actions .mini-btn:hover { background: var(--action-soft); color: var(--text); }
.card-actions .lid-save-btn[aria-pressed="true"] { color: #8a5a00; font-weight: 800; }
body.dark-mode .card-actions .lid-save-btn[aria-pressed="true"] { color: var(--poke-yellow); }
@media (min-width: 768px) {
    #lid-container[data-view="grid"] > .lid-card { margin-bottom: 0; }
}

/* Desktop geography filters stay pinned below the red header. */
@media (min-width: 768px) {
    .nav-sticky-wrapper { position: sticky; top: var(--navigation-clearance, 72px); z-index: 2500; }
    html { scroll-padding-top: calc(var(--navigation-clearance, 72px) + var(--filters-clearance, 100px) + 16px); }
}

/* Local Acts banner: the whole artwork at a smaller size beside its caption;
   the card still opens the full mascot view. */
@media (min-width: 768px) {
    .la-banner-card { display: grid; grid-template-columns: minmax(0, 640px) minmax(0, 1fr); align-items: stretch; }
    .la-banner-img { width: 100%; height: auto; }
    .la-banner-footer { border-top: 0; border-left: 1px solid var(--divider); flex-direction: column; align-items: flex-start; justify-content: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); }
    .la-banner-card:hover .la-banner-hint { background: var(--action-soft); border-color: var(--poke-red); }
}

/* A slightly smaller Poké Ball gives city and Pokémon names more room. */
.lid-card:not(.journal-mode) { --catch-size: 60px; }
@media (min-width: 768px) {
    .lid-card:not(.journal-mode) { --catch-size: 66px; }
}
@media (max-width: 374px) {
    .lid-card:not(.journal-mode) { --catch-size: 52px; }
}

/* Progress footer: always two stats, each with a percentage. */
.stats-percent { color: var(--text-muted); font-weight: 700; }
@media (max-width: 374px) {
    .stats-percent { display: none; }
}

/* Shared compact layout keeps the four collection views consistent. */
body.map-active .collection-sort-field { display: none; }
.save-menu { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); border-top-width: 1px; }
.save-menu .bar-container { height: 4px; margin-bottom: 0; }
/* Fit and expanded-canvas controls are specific to Map. */
.map-actions { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; z-index: 850; }
.map-action-btn { min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font: 800 0.8rem 'Nunito', sans-serif; cursor: pointer; }
.map-action-btn:hover { background: var(--action-soft); border-color: var(--poke-red); }
.map-action-btn:disabled { color: var(--text-muted); cursor: default; }
@media (min-width: 768px) {
    .modern-header { padding: 8px 24px; padding-top: calc(8px + env(safe-area-inset-top)); }
    .nav-desktop-inner { padding-top: 4px; padding-bottom: 4px; }
    .collection-toolbar { padding-top: 6px; padding-bottom: 6px; }
    #collection-heading { font-size: 1.25rem; }
    .collection-filters { gap: 8px; }
    .collection-filters .catch-filter-field label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
@media (max-width: 767px) {
    .collection-toolbar { padding-top: 8px; padding-bottom: 8px; }
    .collection-heading-row #collection-heading { flex-basis: auto; }
    .collection-copy { flex-basis: 100%; }
    .collection-filters { justify-content: flex-end; }
    .map-actions { gap: 6px; right: max(8px, env(safe-area-inset-right)); }
    .map-action-btn { padding-left: 10px; padding-right: 10px; }
}
body.map-expanded { overflow: hidden; }
body.map-expanded > .modern-header,
body.map-expanded > .nav-sticky-wrapper,
body.map-expanded > .save-menu,
body.map-expanded > .skip-link,
body.map-expanded #back-to-top,
body.map-expanded main > :not(#map-container) { display: none; }
body.map-expanded #map-container { position: fixed; inset: 0; z-index: 4000; height: 100vh; height: 100dvh; }
body.map-expanded .leaflet-top { top: env(safe-area-inset-top); }
body.map-expanded .leaflet-bottom { bottom: env(safe-area-inset-bottom); }

/* Each view has one short description; trip actions stay close to their lids. */
.collection-tagline { font-size: 0.8rem; line-height: 1.4; }
.travel-trip-target { margin-top: 10px; color: var(--travel-muted); font-size: 0.8rem; font-weight: 800; overflow-wrap: anywhere; }
.travel-add-button[aria-disabled="true"] { background: var(--caught-surface); color: var(--travel-text); cursor: default; }
.travel-empty-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.travel-section-planner > .travel-form { margin-top: 12px; }

/* Device-only catch review, using the existing sheet and control styling. */
.catch-recovery-overlay { display: none; position: fixed; inset: 0; z-index: 1200; background: rgba(0,0,0,.55); padding: 20px; align-items: center; justify-content: center; }
.catch-recovery-overlay.open { display: flex; }
.catch-recovery-sheet { width: min(100%, 640px); max-height: 90dvh; overflow-y: auto; padding: 24px; border-radius: 18px; background: var(--surface); color: var(--text); }
.catch-recovery-sheet p { margin: 12px 0; }
.catch-recovery-help { font-size: .875rem; }
.catch-recovery-sheet select { display: block; width: 100%; margin: 8px 0; padding: 12px; background: var(--surface); color: var(--text); color-scheme: light; border: 1px solid var(--border); border-radius: 10px; }
.catch-recovery-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.catch-recovery-backup { display: block; margin-top: 12px; }
.catch-recovery-sheet input[type="checkbox"] { margin-right: 8px; }
#catch-recovery-status { overflow-wrap: anywhere; }
@media (max-width: 767px) { .catch-recovery-overlay { padding: 12px; } .catch-recovery-sheet { padding: 18px; } }

.catch-recovery-sheet button:disabled, .catch-recovery-sheet select:disabled { opacity: .5; cursor: not-allowed; }

.catch-recovery-sheet select option { background: var(--surface); color: var(--text); }
body.dark-mode .catch-recovery-sheet select { color-scheme: dark; }

/* Readability: larger, higher-contrast card and progress text. */
.poke-name { font-size: 1rem; color: var(--text); font-weight: 700; }
body.dark-mode .poke-name { color: #e9ebf0; }
.pref-tag { font-size: 0.78rem; letter-spacing: 0.4px; }
body.dark-mode .pref-tag { color: #ffaba4; }
.catch-label { font-size: 0.75rem; color: var(--text-muted); }
body.dark-mode .catch-label { color: #d3d7df; }
.card-actions .mini-btn { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.stats-row { font-size: 0.8rem; }
body.dark-mode .stats-row { color: #e3e5ea; }
body.dark-mode .stats-row .count { color: #ffaba4; }
@media (max-width: 768px) {
    .stats-row { font-size: 0.74rem; }
}

/* Compact phone/PWA chrome; the dock owns the bottom safe-area inset. */
@media (max-width: 767px) {
    :root { --mobile-dock-height: 56px; }
    html { scroll-padding-top: var(--navigation-clearance, 112px); scroll-padding-bottom: calc(var(--collection-bottom-clearance, 112px) + 12px); }
    body { padding-bottom: calc(var(--collection-bottom-clearance, 112px) + 12px); }
    body.map-active { padding-bottom: 0; }
    .modern-header { padding: 6px 12px 8px; padding-top: calc(6px + env(safe-area-inset-top)); }
    .header-top { gap: 8px; margin-bottom: 4px; }
    .header-title { font-size: 1.3rem; letter-spacing: 0; }
    .header-actions { gap: 6px; }
    #poke-search { padding: 8px 12px; min-height: 44px; }
    .header-view-btns { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
    .header-view-btns .view-btn { min-height: 44px; gap: 2px; }
    .header-view-btns .pixel-icon, .header-view-btns .trip-nav-icon { width: 20px; height: 20px; }
    .save-menu { padding: 5px 12px 5px; }
    #bottom-stats-container { gap: 12px; align-items: end; }
    .stats-row { display: grid; gap: 1px; font-size: .74rem; line-height: 1.25; letter-spacing: .25px; margin-bottom: 3px; }
    .stats-row > span:first-child { overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
    .stats-row .count { white-space: nowrap; }
    .stats-percent { display: inline; }
    .back-to-top, .toast, .update-notice { bottom: calc(var(--collection-bottom-clearance, 112px) + 12px); }
    /* Hug the corner so less of the lid cards is covered; keep a 44px target. */
    .back-to-top { right: 6px; bottom: calc(var(--collection-bottom-clearance, 112px) + 6px); }
    .back-to-top.visible { opacity: .9; }
    .collection-toolbar { gap: 6px; padding: 6px 12px; }
    #collection-heading { font-size: 1.15rem; }
    #results-summary { font-size: .75rem; line-height: 1.3; }
    .collection-tagline { margin-top: 2px; font-size: .75rem; line-height: 1.35; }
    .collection-filters { gap: 6px; }
    .collection-sort-field { gap: 6px; }
    #collection-sort { min-height: 44px; padding: 8px 10px; font-size: .875rem; }
    .nearby-btn { min-height: 44px; padding: 8px 10px; font-size: .75rem; }
    body.map-active .collection-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
    body.map-active .collection-copy { width: auto; }
    body.map-active .collection-filters { width: auto; }
}
@media (max-width: 374px) {
    .header-title { font-size: 1.15rem; }
    .header-title span { width: 18px; height: 18px; margin-right: 4px; }
    .filters-toggle { padding-left: 8px; padding-right: 8px; }
    body.map-active #collection-heading { font-size: 1.05rem; }
}

/* Progress tracker: larger text, thicker bars with a visible track, and a
   visible sliver as soon as anything is caught. */
.stats-row { font-size: 0.9rem; letter-spacing: 0.4px; }
.stats-row .count { font-size: 0.95rem; }
.stats-percent { color: var(--text); font-weight: 800; }
.save-menu .bar-container, .progress-stat .bar-container { height: 10px; border-radius: 999px; background: rgba(26, 26, 46, .12); overflow: hidden; }
body.dark-mode .save-menu .bar-container, body.dark-mode .progress-stat .bar-container { background: rgba(255, 255, 255, .16); }
.bar-fill { border-radius: 999px; }
.bar-fill.has-progress { min-width: 10px; }
.save-menu { padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.stats-row { margin-bottom: 5px; }
@media (max-width: 767px) {
    .stats-row { font-size: .8rem; }
    .stats-row .count { font-size: .82rem; }
    .save-menu .bar-container, .progress-stat .bar-container { height: 7px; }
    .bar-fill.has-progress { min-width: 7px; }
    .save-menu { padding: 6px 12px; }
}

/* Contrast: clearer separation between the page and its panels. */
:root { --canvas: #e8ebf0; --border: #c9ced8; }
body.dark-mode { --canvas: #14151e; --surface: #272a3a; --surface-subtle: #2f3345; --border: #5f6680; }

/* Trips: less dead space. */
.travel-layout { gap: var(--space-3); }
.travel-quick-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.travel-quick-nav .travel-btn { padding: 8px 16px; border-radius: 999px; }
.travel-description { margin-top: 4px; }
.travel-form { margin: 12px 0 4px; }
.travel-section-planner > .travel-form { max-width: 640px; }
.travel-empty { margin-top: var(--space-3); padding: var(--space-3) var(--space-4); }
@media (min-width: 768px) {
    .travel-layout { padding: var(--space-4) var(--space-5); }
    .travel-section { padding: var(--space-4) var(--space-5); }
}

/* Trips on wide screens: planner and Saved side by side, Nearby full width below. */
@media (min-width: 1100px) {
    .travel-layout { align-items: stretch; }
    .travel-section-planner { grid-column: auto; }
    .travel-section-planner .travel-list { grid-template-columns: 1fr; }
    .travel-section-planner > .travel-form { max-width: none; }
    #nearby-panel { grid-column: 1 / -1; }
    #nearby-panel .travel-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Trips shortcuts sit beside the Trip planner heading. */
.travel-section-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.travel-section-top .travel-quick-nav { grid-column: auto; }
@media (pointer: fine) {
    .travel-section-top .travel-quick-nav .travel-btn { min-height: 34px; padding: 6px 14px; }
}

/* Readability: darker helper text in light mode and larger Trips / prefecture text. */
:root { --text-muted: #40464f; }
.travel-description, .travel-meta, .travel-status { font-size: 0.92rem; }
.travel-form label, .travel-section > label, .travel-trip-picker label { font-size: 0.88rem; }
.travel-empty { font-size: 0.95rem; color: var(--text-muted); }
.collection-tagline { font-size: 0.88rem; }
#pref-nav button, .nav-desktop-inner #pref-nav button { font-size: 0.88rem; font-weight: 700; }
#pref-nav button:not(.active), .nav-desktop-inner #pref-nav button:not(.active) { color: var(--text); }
@media (max-width: 767px) {
    #pref-nav button { font-size: 0.82rem; }
}

/* Simplify: calmer Journal cards. A red accent replaces the full red header. */
.journal-header-row { background: var(--surface-subtle); border-left: 5px solid var(--poke-red); min-height: 0; padding-top: var(--space-3); padding-bottom: var(--space-3); }
.journal-lid-img { width: 72px; height: 72px; border-color: var(--border); background: var(--surface); }
.journal-city, .journal-poke-name { color: var(--text); }
.journal-poke-name { font-size: 0.9rem; }
.journal-pref-tag { color: #b52724; background: transparent; border-color: currentColor; font-size: 0.66rem; }
body.dark-mode .journal-pref-tag { color: #ffaba4; }
.j-btn-share { background: var(--surface); border-color: var(--border); color: var(--text); }
.journal-photo-placeholder { flex: 1; align-items: flex-start; padding: 0; border: 0; background: transparent; }
body.dark-mode .journal-photo-placeholder { background: transparent; }
/* Empty photo row: the prompt on the left and the camera button inline on the right. */
.journal-photo-wrap:has(.journal-photo-placeholder) { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 8px 6px 16px; line-height: normal; background: var(--surface); border-top: 1px solid var(--divider); }
.journal-photo-wrap:has(.journal-photo-placeholder) .j-btn-cam { position: static; flex-shrink: 0; background: var(--surface-subtle); border-color: var(--border); box-shadow: none; }
.jph-label { font-size: 0.88rem; color: var(--text-muted); }
body.dark-mode .jph-label { color: var(--text-muted); }
.journal-note-display.journal-note-empty { font-size: 0.88rem; text-align: left; }

/* Simplify: lid details show three main actions; the rest sit under More options. */
.lid-details-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lid-details-more { margin-top: 12px; border-top: 1px solid var(--divider); }
.lid-details-more > summary { min-height: 44px; padding: 12px 0; font-weight: 800; font-size: 0.92rem; cursor: pointer; }
.lid-details-more .lid-details-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 4px; }
.lid-details-more .lid-details-trip-form { margin-top: 12px; }
@media (max-width: 420px) {
    .lid-details-actions { grid-template-columns: 1fr 1fr; }
    .lid-details-actions > .travel-btn-primary:first-child { grid-column: 1 / -1; }
}

/* Simplify: show controls only where they do something. */
body.trips-active #nearby-btn, body.journal-active #nearby-btn { display: none; }
body.journal-active #collection-status-field { display: none; }

/* Back-to-top: centred in the space to the right of the cards, just above the progress tracker. */
.back-to-top, .back-to-top.visible { left: auto; right: var(--back-to-top-right, 6px); bottom: calc(var(--collection-bottom-clearance, 64px) + 8px); }
@media (max-width: 767px) {
    .back-to-top, .back-to-top.visible { right: var(--back-to-top-right, 6px); bottom: calc(var(--collection-bottom-clearance, 112px) + 8px); }
}
@media (pointer: fine) and (min-width: 768px) {
    .back-to-top { width: 36px; height: 36px; font-size: 1rem; }
}

/* Shared phone toolbar rows keep sorting and the divider aligned across views. */
@media (max-width: 767px) {
    .collection-toolbar,
    body.map-active .collection-toolbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: minmax(24px, auto) minmax(20px, auto) minmax(20px, auto);
        gap: 4px 8px;
        align-items: center;
    }
    .collection-toolbar .collection-copy,
    .collection-toolbar .collection-heading-row,
    .collection-toolbar .collection-filters { display: contents; }
    .collection-toolbar #collection-heading { grid-column: 1; grid-row: 1; }
    .collection-toolbar #results-summary { grid-column: 1; grid-row: 2; margin: 0; }
    .collection-toolbar .collection-tagline { grid-column: 1 / -1; grid-row: 3; margin: 0; }
    .collection-toolbar #nearby-btn { grid-column: 2; grid-row: 1 / 3; align-self: center; }
    .collection-toolbar .collection-sort-field { grid-column: 1 / -1; grid-row: 4; }
    .collection-toolbar #collection-sort { height: 44px; min-height: 44px; }
    .collection-toolbar #active-filter-chips { grid-column: 1 / -1; grid-row: 5; margin: 0; }
    body.trips-active .collection-toolbar #collection-heading,
    body.journal-active .collection-toolbar #collection-heading,
    body.trips-active .collection-toolbar #results-summary,
    body.journal-active .collection-toolbar #results-summary { grid-column: 1 / -1; }
}


/* Counts sit beside titles; descriptions immediately follow on every phone tab. */
@media (max-width: 767px) {
    .collection-toolbar,
    body.map-active .collection-toolbar {
        grid-template-rows: minmax(48px, auto) auto;
    }
    .collection-toolbar .collection-copy {
        display: grid;
        grid-column: 1;
        grid-row: 1;
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
        width: auto;
    }
    body.trips-active .collection-toolbar .collection-copy,
    body.journal-active .collection-toolbar .collection-copy { grid-column: 1 / -1; }
    .collection-toolbar .collection-heading-row {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 4px 6px;
        min-height: 24px;
    }
    .collection-toolbar .collection-heading-row #collection-heading { flex: 0 1 auto; }
    .collection-toolbar .collection-heading-row #results-summary { flex: 0 1 auto; white-space: nowrap; }
    .collection-toolbar .collection-tagline { grid-column: 1; grid-row: 2; min-height: 20px; }
    .collection-toolbar #nearby-btn { grid-row: 1; }
    .collection-toolbar .collection-sort-field { grid-row: 2; }
    .collection-toolbar #active-filter-chips { flex-basis: 100%; }
}
@media (max-width: 374px) {
    .collection-toolbar .collection-tagline { min-height: 40px; }
}

@media (max-width: 767px) {
    body.map-active .collection-toolbar #results-summary { white-space: normal; }
}

/* Map: Fit and Expand sit in the bottom-right corner, just above the map credits. */
.map-actions { top: auto; bottom: 30px; }
body.map-expanded .map-actions { bottom: calc(30px + env(safe-area-inset-bottom)); }

/* A shared outer edge separates cards from the canvas; row dividers stay softer. */
.lid-card.journal-mode, body.dark-mode .lid-card.journal-mode,
.la-banner-card, body.dark-mode .la-banner-card { border-color: var(--card-border); }

/* Shared outlines apply to every bordered panel/control; separators stay softer. */
:root { --border: var(--card-border); --divider: #c9ced8; }
body.dark-mode { --border: var(--card-border); --divider: #5f6680; }


/* Secondary lid actions are grouped instead of presenting a wall of buttons. */
.lid-details-option-group { margin-top: 12px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.lid-details-option-group > summary { min-height: 44px; padding: 12px 0; font-size: .9rem; font-weight: 800; cursor: pointer; }
.lid-details-option-group[open] { padding-bottom: 12px; }
.lid-details-option-group .lid-details-actions { margin-top: 0; }
.lid-details-option-group .lid-details-trip-form { margin-top: 0; }
.lid-details-option-group .lid-details-trip-form label { font-size: .85rem; }
