:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #f8f6f1;
  --text: #1f2937;
  --muted: #646b78;
  --border: #e5e0d5;
  --navy: #1e3a5f;
  --navy-2: #274b77;
  --gold: #b8862b;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --green-text: #15803d; /* green and gold as text: darker for contrast */
  --gold-text: #8a6417;
  --red: #dc2626;
  --purple: #7c3aed;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #111c33;
    --surface-2: #16223d;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #23314f;
    --navy: #0b1426;
    --navy-2: #1e3a5f;
    --gold: #e0b057;
    --green-bg: #14532d;
    --green-text: #86efac;
    --gold-text: #e0b057;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--navy-2); }
@media (prefers-color-scheme: dark) { a, button.link { color: #93c5fd; } }

h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.6rem max(1.5rem, env(safe-area-inset-right)) 0.6rem max(1.5rem, env(safe-area-inset-left));
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 2000; /* above Leaflet's map controls (1000) */
  flex-wrap: wrap;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.brand-mark { color: var(--gold); }
.topbar nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.nav-main { flex: 1; }
.nav-menu { display: none; }
.topbar nav a { color: #cbd5e1; text-decoration: none; padding: 0.35rem 0.7rem; border-radius: 6px; }
.topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.topbar nav a.active { color: #fff; background: rgba(255, 255, 255, 0.15); }

.main { max-width: 1200px; margin: 0 auto; padding: 1.5rem max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left)); }
.main-full { padding: 0; }
.site-footer { max-width: 1200px; margin: 0 auto; padding: 1rem max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem; justify-content: space-between; color: var(--muted); font-size: 0.85rem; }
.site-footer a { color: inherit; }
.legal { max-width: 46rem; line-height: 1.6; }
.legal h2 { margin-top: 1.75rem; font-size: 1.15rem; }
.legal li { margin: 0.3rem 0; }

.banner { padding: 0.6rem 1.5rem; }
.banner-info { background: #dbeafe; color: #1e40af; }
.banner-error { background: #fee2e2; color: #991b1b; border-radius: 6px; margin-bottom: 1rem; }
.main .banner-error { padding: 0.6rem 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.map-card { padding: 0; overflow: hidden; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.subtitle { color: var(--muted); margin-top: 0.2rem; }
.badges { margin-top: 0.5rem; display: flex; gap: 0.35rem; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-2 > .card { margin-bottom: 1.25rem; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; gap: 0; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1.1rem; box-shadow: var(--shadow); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--navy-2); line-height: 1.1; }
@media (prefers-color-scheme: dark) { .stat-value { color: var(--gold); } }
.stat-label { color: var(--muted); font-size: 0.85rem; }

.map { height: 460px; width: 100%; }
.map-small { height: 320px; border-radius: 6px; }
.map-full { height: calc(100vh - 52px); }
body:has(> .main-full) { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
body:has(> .main-full) > .main-full { flex: 1; min-height: 0; }
body:has(> .main-full) .map-full { height: 100%; }
.leaflet-container { font: inherit; }
.map-legend { background: rgba(255, 255, 255, 0.92); color: #1f2937; padding: 6px 10px; border-radius: 6px; font-size: 12px; line-height: 1.7; box-shadow: var(--shadow); }
.map-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.map-legend .dot.hollow { border: 1.5px solid #64748b; background: rgba(100, 116, 139, 0.15); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table thead th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.table tbody tr:last-child td, .table tr:last-child th, .table tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 0.35rem 0.5rem; }
.table.kv th { width: 9rem; color: var(--muted); font-weight: 500; }
.row-visited { background: color-mix(in srgb, var(--green-bg) 45%, transparent); }
.card > .table { display: block; overflow-x: auto; }
.right { text-align: right !important; }
.nowrap { white-space: nowrap; }
.notes { max-width: 26rem; white-space: pre-line; } /* keeps the line breaks of trip notes */
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.danger { color: var(--red); }
.empty { color: var(--muted); font-style: italic; }
.hidden { display: none !important; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.02em; }
.stars { color: var(--gold-text); white-space: nowrap; }
.actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.actions > .btn, .actions > form { flex: none; }

.badge { display: inline-block; font-size: 0.72rem; padding: 0.08rem 0.45rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge-visited { background: var(--green-bg); color: var(--green-text); border-color: transparent; font-weight: 600; }
.badge-private { color: var(--purple); border-color: color-mix(in srgb, var(--purple) 40%, transparent); }
.badge-large_airport { color: #2563eb; }
.badge-heliport { color: #d97706; }
.badge-seaplane_base { color: #0284c7; }
.badge-closed { text-decoration: line-through; }

.btn { display: inline-block; padding: 0.45rem 0.9rem; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #1a1405; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.05); border-color: var(--gold); }
button.link { background: none; border: 0; padding: 0; color: var(--navy-2); font: inherit; cursor: pointer; text-decoration: underline; }
button.link.danger { color: var(--red); }

.search { display: flex; gap: 0.6rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.search input[type=search] { flex: 1; min-width: 240px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 7px; padding: 0.45rem 0.6rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--gold) 60%, transparent); outline-offset: 0; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
.check { display: flex; gap: 0.45rem; align-items: center; margin: 0.3rem 0; cursor: pointer; }

.form-card { max-width: 760px; }
.form .field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; flex: 1; min-width: 0; }
.form .field > label, .form .field-label { font-weight: 600; font-size: 0.88rem; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row .field { min-width: 200px; }
.form-actions { display: flex; gap: 0.6rem; margin-top: 0.5rem; }
.rating { display: flex; gap: 1rem; flex-wrap: wrap; }
.rating label { display: flex; gap: 0.25rem; align-items: center; cursor: pointer; }
.picked { padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.picker-results { display: flex; flex-direction: column; margin-top: 0.3rem; border-radius: 7px; overflow: hidden; }
.picker-results:not(:empty) { border: 1px solid var(--border); }
.picker-option { text-align: left; background: var(--surface); color: var(--text); border: 0; border-bottom: 1px solid var(--border); padding: 0.5rem 0.7rem; font: inherit; cursor: pointer; }
.picker-option:last-child { border-bottom: 0; }
.picker-option:hover { background: var(--surface-2); }

.progress { height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; display: inline-block; width: 100%; max-width: 220px; vertical-align: middle; }
.progress > div { height: 100%; background: var(--gold); }

.milestone-list { display: flex; flex-direction: column; gap: 0.6rem; }
.milestone-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.milestone { display: flex; gap: 0.75rem; padding: 0.7rem 0.8rem; border: 1px dashed var(--border); border-radius: 8px; opacity: 0.75; }
.milestone.achieved { opacity: 1; border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent); background: color-mix(in srgb, var(--gold) 8%, var(--surface)); }
.milestone-icon { font-size: 1.6rem; line-height: 1; filter: grayscale(1); }
.milestone.achieved .milestone-icon { filter: none; }
.milestone-body { min-width: 0; flex: 1; }
.milestone-title { font-weight: 650; }
.milestone-desc { color: var(--muted); font-size: 0.85rem; }
.milestone-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }

/* Passport stamp grid */
.state-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 0.45rem; }
.stamp {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  aspect-ratio: 1; border: 1.5px dashed var(--border); border-radius: 8px;
  text-decoration: none; color: var(--muted); background: var(--surface-2);
}
.stamp-code { font-weight: 700; font-family: ui-monospace, Menlo, monospace; }
.stamp-count { font-size: 0.75rem; }
.stamp:hover { border-color: var(--muted); }
.stamp-visited {
  border: 2px solid var(--navy-2); color: var(--navy-2); background: color-mix(in srgb, var(--navy-2) 8%, var(--surface));
  transform: rotate(-4deg);
}
.stamp-visited:nth-child(2n) { transform: rotate(3deg); border-color: var(--gold); color: var(--gold-text); background: color-mix(in srgb, var(--gold) 10%, var(--surface)); }
.stamp-visited:nth-child(3n) { transform: rotate(-1deg); border-color: var(--green); color: var(--green-text); background: color-mix(in srgb, var(--green) 8%, var(--surface)); }
@media (prefers-color-scheme: dark) { .stamp-visited { color: #93c5fd; border-color: #93c5fd; } }

.pro-features { display: grid; align-items: start; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.pro-features .card { margin: 0; }
.feature-list { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.35rem; }
.pro-cta { text-align: center; }
.pro-plans { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.pro-plan { margin: 0; }
.pro-notice { border-radius: 6px; margin-bottom: 1rem; padding: 0.6rem 1rem; }
.badge-pro { background: var(--navy-2); color: #fff; border-color: transparent; font-weight: 600; letter-spacing: 0.02em; }
.plan { margin-top: 0.35rem; font-size: 0.9rem; }
.badge-home { background: color-mix(in srgb, var(--gold) 18%, var(--surface)); color: var(--gold-text); border-color: color-mix(in srgb, var(--gold) 50%, transparent); font-weight: 600; }
.home-bar { margin: -0.25rem 0 1rem; }
.date-picker { display: flex; gap: 0.5rem; }
.date-picker input { flex: 1; min-width: 0; }
.form .field-narrow { flex: 0 0 8rem; min-width: 8rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: -0.4rem 0 0.9rem; }
.autosave-status { min-height: 1.2em; margin: 0.25rem 0 0; color: var(--green-text); }
.autosave-status.danger { color: var(--red); }

/* Flights */
.banner-ok { background: var(--green-bg); color: var(--green-text); border-radius: 6px; margin-bottom: 1rem; padding: 0.6rem 1rem; }
form.inline { display: inline; }
.mono, code { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.flight-entry textarea { font-size: 0.95rem; line-height: 1.6; min-height: 14rem; }
.entry-help { flex: 0 1 22rem; font-size: 0.88rem; color: var(--muted); }
.entry-help p { margin: 0.3rem 0; }
.entry-help ul { padding-left: 1.1rem; margin: 0.3rem 0; }
.entry-help li { margin-bottom: 0.3rem; }
.entry-help code { color: var(--text); background: var(--surface-2); padding: 0 0.25rem; border-radius: 4px; }
.row-error { background: color-mix(in srgb, var(--red) 10%, transparent); }
.row-skip { opacity: 0.55; }
.warn { color: #b45309; }
@media (prefers-color-scheme: dark) { .warn { color: #fbbf24; } }
.route-stop { white-space: nowrap; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.banner-ok a, .banner-ok button.link { color: inherit; font-weight: 600; }
@media (prefers-color-scheme: dark) { .banner-ok { color: #bbf7d0; } }
.map-legend .dot.dashed { border-style: dashed; }
.form .field-narrow:has(input[type=date]) { flex-basis: 11rem; }
.restore-form { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.restore-form input[type=file] { flex: 1; min-width: 0; }
.map-toggle { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; user-select: none; }
.route-swatch { display: inline-block; width: 16px; height: 0; border-top: 2.5px solid #7c3aed; vertical-align: middle; margin-right: 2px; }
.map-legend summary { cursor: pointer; font-weight: 600; }
.map-legend details[open] summary { margin-bottom: 2px; }

/* Wishlist */
.badge-wish { background: color-mix(in srgb, #ec4899 14%, var(--surface)); color: #db2777; border-color: color-mix(in srgb, #ec4899 45%, transparent); font-weight: 600; }
@media (prefers-color-scheme: dark) { .badge-wish { color: #f9a8d4; } }
.wish-form { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.wish-form label { font-weight: 600; }
.wish-form input { flex: 1; min-width: 12rem; }
.wish-card p { margin: 0.5rem 0 0; }
.page-head > .actions form { display: inline; }
.airport-note { display: flex; flex-direction: column; gap: 0.6rem; }
.route-preview { margin-top: 0.4rem; line-height: 1.8; }
.picker { margin-top: 0.3rem; }
.picker input[type=search] { width: 100%; }

/* ⌘/Ctrl + scroll to zoom on embedded maps */
.map-zoom-note {
  position: absolute; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.45); color: #fff; font-size: 1.15rem; font-weight: 600; text-align: center;
  pointer-events: none; opacity: 0; transition: opacity 0.25s;
}
.map-zoom-note.show { opacity: 1; }
.map-zoom-hint { font-size: 11px; padding: 2px 8px; opacity: 0.85; }

/* Explore */
.explore-form .field-row { align-items: flex-end; }
.explore-form .field-row.explore-top { align-items: flex-start; }
.explore-top > .field:not(.field-narrow) { flex: 0 1 auto; }
.range-row { display: flex; gap: 0.4rem; align-items: center; }
.range-row input { width: 6rem; }
.presets { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.4rem; }
.chip { display: inline-flex; gap: 0.3rem; align-items: center; font: inherit; font-size: 0.82rem; padding: 0.2rem 0.6rem;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--muted); }
/* Place filters: checkboxes shown as toggle chips, big enough to tap. */
.poi-chips { border: 0; padding: 0; margin: 0 0 0.9rem; min-width: 0; }
.poi-chips legend { font-weight: 600; font-size: 0.88rem; padding: 0; margin-bottom: 0.35rem; }
.poi-chips legend .muted { font-weight: normal; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip.toggle { position: relative; padding: 0.35rem 0.75rem; font-size: 0.88rem; user-select: none; }
.chip.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.chip.toggle:has(input:checked) { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.chip.toggle:has(input:checked)::before { content: "✓"; }
.chip.toggle:has(input:focus-visible) { outline: 2px solid color-mix(in srgb, var(--gold) 60%, transparent); outline-offset: 1px; }
.explore-options { gap: 1.2rem; align-items: center; }
.inline-field { display: flex; gap: 0.4rem; align-items: center; }
.inline-field input { width: 5rem; }
.explore-summary { margin: 0 0 0.8rem; }
.map-explore { height: 380px; }
.map-passport { height: 400px; }
.passport-link { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.passport-link code { overflow-wrap: anywhere; }
.suggestions { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1rem; }
.suggestions .card { margin: 0; }
.suggestion { display: flex; flex-direction: column; gap: 0.55rem; }
.suggestion-head { display: flex; justify-content: space-between; gap: 0.8rem; }
.suggestion-nav { text-align: right; white-space: nowrap; }
.reasons { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip.reason { cursor: default; background: color-mix(in srgb, var(--gold) 12%, var(--surface)); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.suggestion-facts { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; color: var(--muted); }
.food { line-height: 1.6; }
.suggestion-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: auto; flex-wrap: wrap; }
.suggestion-actions .btn { padding: 0.3rem 0.7rem; font-size: 0.88rem; }
.attribution { margin-top: 1rem; }

/* Background jobs */
.jobs-pill { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.3rem 0.75rem; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12); color: #fff; text-decoration: none; font-size: 0.85rem; white-space: nowrap; }
.jobs-pill:hover { background: rgba(255, 255, 255, 0.2); }
.pill-bar { display: inline-block; width: 48px; height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.pill-bar > span { display: block; height: 100%; background: var(--gold); transition: width 0.4s; }
.spinner { display: inline-block; width: 0.8em; height: 0.8em; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -0.1em; opacity: 0.8; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.badge-running { background: #dbeafe; color: #1e40af; border-color: transparent; font-weight: 600; }
.progress-lg { height: 10px; max-width: none; }
.progress > div { transition: width 0.4s; }
.progress-row { display: flex; gap: 0.8rem; align-items: center; margin: 0.3rem 0 0.6rem; }
.progress-row .progress { flex: 1; }
.progress-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 1rem; margin-bottom: 1rem; }
.progress-card .progress-lg { display: block; margin: 0.4rem 0; }
.progress-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.card h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; }
ul.plain { list-style: none; padding: 0; margin: 0 0 0.6rem; line-height: 1.8; }

/* Profiles */
.user-link { color: #cbd5e1; text-decoration: none; padding: 0.35rem 0.7rem; border-radius: 6px; white-space: nowrap; }
.user-link:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.user-link.active { color: #fff; background: rgba(255, 255, 255, 0.15); }
.banner-warn { background: #fef3c7; color: #92400e; }
.banner-warn a { color: inherit; font-weight: 600; }
.login-card { max-width: 380px; margin: 3rem auto; }
.login-card .form-actions .btn { width: 100%; }

/* Autocomplete dropdown (Explore's From field) */
.autocomplete { position: relative; }
.autocomplete input { width: 100%; }
.autocomplete-list { position: absolute; top: 100%; left: 0; z-index: 1100; min-width: min(26rem, 90vw);
  margin-top: 0.2rem; background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15); }
.autocomplete-list:empty { display: none; }
.picker-option:focus { outline: none; background: color-mix(in srgb, var(--gold) 18%, var(--surface)); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.food-row.food-closed { color: var(--muted); }
.food-row button.link { vertical-align: baseline; }
.secret { display: block; margin: 0.4rem 0; word-break: break-all; user-select: all; font-weight: 600; }
.secret-banner code.secret { color: inherit; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }

/* Photos */
.notes-input { min-height: 8rem; line-height: 1.5; resize: vertical; }
.photo-upload { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.photo-upload input[type=file] { flex: 1; min-width: 0; max-width: 100%; padding: 0.35rem; }
.photo-stop { display: flex; gap: 0.4rem; align-items: center; color: var(--muted); font-size: 0.88rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 1rem; }
.photo-item { margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.photo-link { display: block; border-radius: 7px; overflow: hidden; background: var(--surface-2); aspect-ratio: 4 / 3; }
.photo-link img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-edit { display: flex; gap: 0.35rem; }
.photo-edit input { flex: 1; min-width: 0; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.photo-status { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.review-pill { text-decoration: none; }
.review-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 1rem; }
.review-item { margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.review-item img { width: 100%; border-radius: var(--radius); }
.photo-strip { display: flex; gap: 0.75rem; overflow-x: auto; padding-bottom: 0.4rem; scroll-snap-type: x proximity; }
.photo-thumb { margin: 0; flex: 0 0 auto; width: 160px; scroll-snap-align: start; }
.photo-thumb figcaption { margin-top: 0.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-count { text-decoration: none; white-space: nowrap; }
.lightbox { padding: 0; border: 0; margin: 0; max-width: 100vw; max-height: 100dvh; width: 100vw; height: 100dvh; background: rgba(0, 0, 0, 0.92); }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.5); }
.lightbox[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lightbox img { max-width: 100vw; object-fit: contain;
  max-height: calc(100dvh - 4rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.lightbox-caption { color: #e5e7eb; margin: 0.6rem 1rem env(safe-area-inset-bottom); text-align: center; min-height: 1.2em; }
html:has(.lightbox[open]) { overflow: hidden; }
.lightbox button { position: absolute; background: rgba(0, 0, 0, 0.45); color: #fff; border: 0; font-size: 2rem; line-height: 1;
  width: 2.75rem; height: 2.75rem; border-radius: 50%; cursor: pointer; }
.lightbox-close { top: 0.75rem; right: 0.75rem; }
.lightbox-prev { left: 0.5rem; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 0.5rem; top: 50%; transform: translateY(-50%); }

/* Airfield panel: a drawer beside the map, a bottom sheet on phones */
.airport-panel {
  position: fixed; z-index: 1500; /* above Leaflet's controls, below the top bar */
  top: var(--panel-top, 52px); right: 0; bottom: 0; width: 420px; max-width: 100vw;
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
}
.airport-panel[hidden] { display: none; }
.panel-bar { display: flex; justify-content: flex-end; align-items: center; padding: 0.35rem 0.4rem 0; flex: none; }
.panel-close { background: none; border: 0; color: var(--muted); font: inherit; font-size: 1.1rem; line-height: 1;
  width: 2.25rem; height: 2.25rem; border-radius: 50%; cursor: pointer; }
.panel-close:hover { background: var(--surface-2); color: var(--text); }
.panel-grip { display: none; }
.panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 1.1rem 1.25rem; margin-top: -0.9rem; }
.panel-body:focus { outline: none; }
.panel-body h1 { font-size: 1.3rem; padding-right: 2rem; }
.panel-body h1:focus { outline: none; }
.panel-body .actions { flex-wrap: wrap; gap: 0.45rem; margin-top: 0.85rem; }
.panel-body .actions .btn { padding: 0.35rem 0.7rem; font-size: 0.88rem; }
.panel-body .card { background: none; border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none;
  padding: 0.9rem 0 0; margin: 1rem 0 0; }
.panel-body .table.kv th { width: 7rem; }
.panel-summary { margin: 0.8rem 0 0; color: var(--muted); }
.panel-foot { margin: 1.25rem 0 0; }
.panel-error { margin-top: 1.5rem; }
.panel-skeleton { padding-top: 0.9rem; }
.sk { background: var(--surface-2); border-radius: 6px; margin-bottom: 0.7rem; animation: sk-pulse 1.2s ease-in-out infinite alternate; }
.sk-title { height: 1.6rem; width: 70%; }
.sk-line { height: 0.9rem; width: 55%; }
.sk-line.short { width: 35%; }
.sk-block { height: 7rem; margin-top: 1.2rem; }
@keyframes sk-pulse { to { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
/* Keep the map's own controls clear of the drawer. */
body.panel-open .map-full .leaflet-right { right: 420px; }

@media (max-width: 767px) {
  .airport-panel {
    top: auto; left: 0; width: auto; height: 45dvh;
    border-left: 0; border-top: 1px solid var(--border); border-radius: 14px 14px 0 0; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
    transition: height 0.2s;
  }
  .airport-panel.expanded { height: calc(100dvh - var(--panel-top, 96px)); border-radius: 0; }
  .panel-bar { justify-content: center; position: relative; padding-top: 0.2rem; }
  .panel-grip { display: flex; align-items: center; justify-content: center; width: 5rem; height: 1.8rem;
    background: none; border: 0; cursor: pointer; }
  .panel-grip span { width: 2.5rem; height: 5px; border-radius: 999px; background: var(--border); }
  .panel-close { position: absolute; right: 0.4rem; top: 0.15rem; }
  .panel-body { margin-top: 0; }
  body.panel-open .map-full .leaflet-right { right: 0; }
  body.panel-open .map-full .leaflet-bottom { bottom: 45dvh; }
}
@media (max-width: 767px) and (prefers-reduced-motion: reduce) { .airport-panel { transition: none; } }

/* Search box on the map */
.map-search { position: relative; width: min(20rem, calc(100vw - 5rem)); }
.map-search input { width: 100%; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25); border-color: rgba(0, 0, 0, 0.2); }
.map-search-results { position: absolute; top: 100%; left: 0; right: 0; margin-top: 0.2rem; max-height: 60vh; overflow-y: auto;
  background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); }
.map-search-results:empty { display: none; }
.map-search-results .picker-option { font-size: 0.9rem; }
.map-search-none { padding: 0.5rem 0.7rem; }

.lightbox-close { top: max(0.75rem, env(safe-area-inset-top)); right: max(0.75rem, env(safe-area-inset-right)); }
.lightbox-prev { left: max(0.5rem, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%); }
.lightbox-next { right: max(0.5rem, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); }

/* ---------- Tablets and phones ---------- */

/* Header menu: a hamburger that opens the links as a panel under the bar. */
.nav-menu summary { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: 8px; color: #fff; cursor: pointer; list-style: none; background: rgba(255, 255, 255, 0.08); }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu[open] summary { background: rgba(255, 255, 255, 0.18); }
.menu-icon, .menu-icon::before, .menu-icon::after { display: block; width: 20px; height: 2px; border-radius: 1px; background: currentColor; }
.menu-icon { position: relative; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; transition: transform 0.15s; }
.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }
.nav-menu[open] .menu-icon { background: transparent; }
.nav-menu[open] .menu-icon::before { top: 0; transform: rotate(45deg); }
.nav-menu[open] .menu-icon::after { top: 0; transform: rotate(-45deg); }
.nav-menu nav { position: absolute; left: 0; right: 0; top: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.25rem;
  padding: 0.5rem max(1rem, env(safe-area-inset-right)) 1rem max(1rem, env(safe-area-inset-left)); background: var(--navy);
  border-top: 1px solid rgba(255, 255, 255, 0.1); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25); max-height: calc(100dvh - 60px); overflow-y: auto; }
.nav-menu nav a { display: flex; align-items: center; min-height: 44px; padding: 0.5rem 0.9rem; }

/* The jobs pill shrinks to a spinner and a bar, leaving the header room for
   the links; its words stay for screen readers (and in its tooltip). */
@media (max-width: 1400px) {
  .topbar { gap: 0.5rem 1rem; }
  .topbar .nav-main a { padding-left: 0.55rem; padding-right: 0.55rem; }
  .jobs-pill { padding: 0.45rem 0.7rem; }
  .jobs-pill .pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* Logged in, the nine links fold into the menu. */
@media (max-width: 1200px) {
  .has-menu { gap: 0.5rem 0.75rem; }
  .has-menu .brand { flex: 1; min-width: 0; }
  .has-menu .nav-main, .has-menu .user-link { display: none; }
  .has-menu .nav-menu { display: block; }
}

@media (max-width: 900px) {
  .topbar { gap: 0.5rem 0.75rem; padding: 0.5rem max(1rem, env(safe-area-inset-right)) 0.5rem max(1rem, env(safe-area-inset-left)); }
  .topbar .brand { flex: 1; min-width: 0; }
  /* Visitors have three links: they stay visible, on a row of their own. */
  .topbar:not(.has-menu) .nav-main { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .topbar nav a { white-space: nowrap; }
  .topbar:not(.has-menu) .nav-main a { padding: 0.6rem 0.8rem; }
  .main { padding: 1rem max(1rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
}

@media (max-width: 640px) {
  h1 { font-size: 1.4rem; }
  .card { padding: 1rem 0.9rem; margin-bottom: 1rem; }
  .card.map-card { padding: 0; }
  .grid-2 > .card { margin-bottom: 1rem; }
  .page-head { margin-bottom: 1rem; align-items: flex-start; }
  .login-card { margin: 1rem auto; }
  .banner { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }

  .jobs-pill { padding: 0.55rem 0.7rem; }
  .pill-bar { width: 28px; }
  .btn-log { padding: 0.6rem 0.9rem; }

  .stats { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
  .stat { padding: 0.6rem 0.75rem; }
  .stat-value { font-size: 1.45rem; }
  .stat-label { font-size: 0.8rem; line-height: 1.3; }
  .state-grid { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); }

  /* Maps leave room above and below to scroll the page past them. */
  .map { height: min(460px, 60vh); }
  .map-small { height: min(280px, 45vh); }
  .map-explore { height: min(380px, 55vh); }
  .leaflet-container .leaflet-control-attribution { font-size: 10px; line-height: 1.4; }
  .map-legend { font-size: 11px; line-height: 1.6; }

  /* Forms: one field per row (selects two to a row), full width. */
  .field-row, .explore-form .field-row { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; }
  .field-row > .field, .field-row > .entry-help, .form .field-narrow, .form .field-narrow:has(input[type=date]) { flex: none; min-width: 0; }
  .entry-help { margin-bottom: 0.9rem; }
  .field-row.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 0.75rem; }
  .field-row.explore-options { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.2rem; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 auto; text-align: center; }
  .search input[type=search] { flex-basis: 100%; min-width: 0; }
  .search select { flex: 1; min-width: 0; }
  .wish-form input, .restore-form input[type=file] { flex-basis: 100%; min-width: 0; }
  .table.kv th { width: 7rem; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 0.75rem; }
  .photo-edit { flex-wrap: wrap; }
  .photo-edit input { flex-basis: 100%; }
  .photo-edit select { flex: 1; min-width: 0; }
  .table th, .table td, .table.compact th, .table.compact td { padding-left: 0.4rem; padding-right: 0.4rem; }
  .table thead th { font-size: 0.72rem; letter-spacing: 0.02em; }

  /* Tables with many columns become one card per row. */
  .table.cards, .card > .table.cards, .table.cards tbody { display: block; overflow: visible; }
  .table.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table.cards tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; padding: 0.7rem 0.4rem;
    border-bottom: 1px solid var(--border); }
  .table.cards tr:last-child { border-bottom: 0; }
  .table.cards td, .table.cards th { display: block; padding: 0; border: 0; }
  .table.cards td.actions { display: flex; }
  .table.cards .right { text-align: left !important; }
  .table.cards td:empty { display: none; }
  .table.cards [data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: 0.8rem; }
  .table.cards .notes { max-width: none; flex-basis: 100%; }

  .entry-table .c-date { order: 1; font-weight: 600; }
  .entry-table .c-dist { order: 2; margin-left: auto; }
  .entry-table .c-ldg { order: 3; }
  .entry-table .c-ldg::before { content: "· "; color: var(--muted); }
  .entry-table .c-ldg::after { content: " " attr(data-unit); color: var(--muted); }
  .entry-table .c-route { order: 4; flex-basis: 100%; font-size: 1.05rem; }
  .entry-table .c-aircraft { order: 5; flex-basis: 100%; font-size: 0.88rem; }
  .entry-table .c-notes { order: 6; }
  .entry-table .c-actions { order: 7; flex-basis: 100%; gap: 1.5rem; }

  .airport-table .c-name { flex: 1 1 0; min-width: 0; }
  .airport-table .c-where { flex-basis: 100%; color: var(--muted); font-size: 0.88rem; }
  .airport-table .c-elev, .airport-table .c-rwy { font-size: 0.88rem; }
  .airport-table .c-visits { margin-left: auto; }

  .wish-table .c-name { flex-basis: 100%; }
  .wish-table .c-where, .wish-table .c-dist { font-size: 0.88rem; color: var(--muted); }
  .wish-table .c-dist::after { content: " from home"; }
  .wish-table .c-status { font-size: 0.88rem; }
  .wish-table .c-actions { margin-left: auto; gap: 1.25rem; }

  .state-table .c-name { flex: 1 1 0; min-width: 0; }
  .table.cards td.c-progress { flex-basis: 100%; display: flex; align-items: center; gap: 0.5rem; }
  .state-table .c-progress .progress { max-width: none; flex: 1; }
  .state-table .c-first, .state-table .c-last { font-size: 0.88rem; }

  .visited-table .c-name { flex: 1 1 60%; }
  .visited-table .c-where, .visited-table .c-ldg, .visited-table .c-last { font-size: 0.88rem; color: var(--muted); }

  .user-table .c-name { flex-basis: 100%; }
  .user-table .c-actions { flex-basis: 100%; flex-wrap: wrap; gap: 0.3rem 0.6rem; }

  .preview .c-num::after { content: "."; }
  .preview .c-date { font-weight: 600; }
  .preview .c-route, .preview .c-error { flex-basis: 100%; }

  .records th { flex: 1; font-weight: 600; }
  .records td.right { order: 2; }
  .records td:not(.right) { order: 3; flex-basis: 100%; }

  .runways tr { gap: 0.2rem 0.8rem; }
  .runways .c-name { min-width: 3.5rem; }
  .runways .c-length { margin-right: -0.4rem; }
  .runways .c-width::before { content: "× "; color: var(--muted); }

  .events .c-took { margin-left: auto; }
  .events .c-result, .failed .c-error { order: 5; flex-basis: 100%; overflow-wrap: anywhere; }
}

/* Inputs at 16px or more, so iOS doesn't zoom in on focus. */
@media (max-width: 640px), (pointer: coarse) {
  input, select, textarea, .flight-entry textarea { font-size: 16px; }
}

/* Bigger touch targets for fingers. */
@media (pointer: coarse) {
  .btn { padding: 0.6rem 1rem; }
  .btn-small, .suggestion-actions .btn { padding: 0.5rem 0.8rem; }
  .chip.toggle { padding: 0.5rem 0.85rem; }
  .chip[data-action=preset] { padding: 0.4rem 0.75rem; }
  .check { padding: 0.35rem 0; }
  .actions a, .actions button.link { padding: 0.4rem 0; }
  .picker-option { padding: 0.7rem 0.8rem; }
}

@media (max-width: 400px) {
  .topbar { gap: 0.5rem; }
  .brand { font-size: 1rem; }
  .jobs-pill .pill-bar { display: none; }
}
@media (max-width: 360px) {
  .brand-first { display: none; }
}

@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; }
}

/* Place ratings */
.poi-stars { color: var(--gold); font-weight: 600; white-space: nowrap; }
/* inline-block: an inline <details> still breaks the line in Chrome. */
details.rate { display: inline-block; }
details.rate[open] { display: inline-flex; align-items: center; }
details.rate > summary { display: inline; cursor: pointer; list-style: none; text-decoration: underline; }
details.rate > summary::-webkit-details-marker { display: none; }
details.rate[open] > summary { text-decoration: none; }
.rate-stars { display: inline-flex; align-items: center; gap: 0.05rem; margin-left: 0.3rem; vertical-align: -0.1em; }
.rate-star { background: none; border: 0; padding: 0 0.1rem; font: inherit; font-size: 1.15rem; line-height: 1; color: var(--border); cursor: pointer; }
.rate-star.on { color: var(--gold); }
/* Hovering previews the rating: the star and those before it light up. */
.rate-stars:hover .rate-star { color: var(--gold); }
.rate-stars .rate-star:hover ~ .rate-star { color: var(--border); }
.rate-stars .link { margin-left: 0.35rem; }
@media (pointer: coarse) { .rate-star { font-size: 1.5rem; padding: 0.15rem 0.2rem; } }
.poi-more { margin-top: 0.2rem; }
.poi-more > summary { cursor: pointer; color: var(--muted); }
.poi-more[open] > summary { margin-bottom: 0.2rem; }
