/* Countries Passport: plain CSS, light and dark. No inline styles (CSP style-src 'self').
   Look: "Passport" (navy cover header, gold foil, stamp red, paper pages;
   DM Serif Display headings, Courier Prime for stamps and codes, Inter for text). */
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "DM Serif Display";
  src: url("../fonts/dm-serif-display-latin-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Courier Prime";
  src: url("../fonts/courier-prime-latin-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Courier Prime";
  src: url("../fonts/courier-prime-latin-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "DM Serif Display", Georgia, "Times New Roman", serif;
  --font-mono: "Courier Prime", "Courier New", ui-monospace, monospace;

  --bg: #f4f1ea;              /* passport paper */
  --surface: #fffdf8;         /* cards */
  --surface-2: #efe9dc;       /* rules, subtle fills */
  --text: #1b2a4a;
  --muted: #5a6680;
  --border: #d8d1c0;
  --navy: #1b2a4a;            /* cover: header */
  --cover: #1b2a4a;           /* passport cover panels */
  --on-navy: #f4f1ea;
  --gold: #e3c27a;            /* foil */
  --stamp: #b23a2e;           /* visited, primary action */
  --stamp-text: #ffffff;
  --ink: #1b2a4a;             /* second stamp colour */
  --link: #1f4590;
  --focus: #b23a2e;
  --land: #e4ddcd;            /* map: not visited */
  --select: #b8862a;          /* map: selected outline (differs from visited and shared) */
  --wish: #7d9cc4;            /* map: wishlist (not yet visited) */
  --land-line: #fffdf8;
  --sea: #fffdf8;
  --ok-bg: #e9f5ec; --ok-text: #1d5b30;
  --err-bg: #fbeceb; --err-text: #8a231a;
  --info-bg: #eaeff8; --info-text: #1b2a4a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(27, 42, 74, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1729;
    --surface: #17223a;
    --surface-2: #1f2c48;
    --text: #ece6d8;
    --muted: #a9b2c6;
    --border: #2c3a57;
    --navy: #0a1222;
    --cover: #1a2a4d;
    --on-navy: #ece6d8;
    --stamp: #e06a5c;
    --stamp-text: #1a0d0b;
    --ink: #e3c27a;
    --link: #e8c97f;
    --focus: #e3c27a;
    --land: #2a3550;
    --select: #ffffff;
    --wish: #5f86b8;
    --land-line: #17223a;
    --sea: #17223a;
    --ok-bg: #173a24; --ok-text: #cdeed7;
    --err-bg: #4a1a16; --err-text: #fbd9d5;
    --info-bg: #1f2c48; --info-text: #e3e8f3;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.1; margin: 0 0 .5rem; }
h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1rem; }
img, svg { max-width: 100%; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 1rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Header (the passport cover) ---- */
.site-header { background: var(--navy); color: var(--on-navy); }
.header-inner { max-width: 1100px; margin: 0 auto; padding: .9rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--gold); text-decoration: none; }
.brand-word { font-family: var(--font-display); font-size: 1.5rem; letter-spacing: .08em; text-transform: uppercase; }
.main-nav { display: flex; flex-wrap: wrap; gap: .35rem; flex: 1 1 auto; }
.main-nav a { color: var(--on-navy); text-decoration: none; padding: .55rem 1rem; border-radius: 999px; min-height: 44px; display: inline-flex; align-items: center; }
.main-nav a:hover { background: rgba(255, 255, 255, .08); }
.main-nav a[aria-current="page"] { background: var(--gold); color: #1b2a4a; font-weight: 600; }
.user-nav { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.avatar { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--gold); color: var(--gold); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; text-decoration: none; }
.avatar[aria-current="page"] { background: var(--gold); color: #1b2a4a; }

/* ---- Page ---- */
.container { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1rem 3rem; }
.container-wide { max-width: 1360px; }
.narrow { max-width: 34rem; margin: 2rem auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.eyebrow { font-family: var(--font-mono); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 .25rem; }
.lead { font-size: 1.125rem; color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }

/* ---- Cards ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1.25rem; }
.card-ruled { background-image: repeating-linear-gradient(0deg, transparent 0 27px, var(--surface-2) 27px 28px); }
.card-navy { background: var(--cover); color: var(--on-navy); border-color: var(--cover); }
.card-navy h2, .card-navy h3 { color: var(--gold); }

/* ---- Stamps ---- */
.stamp-row { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.5rem 0; }
.stamp { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  font-family: var(--font-mono); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; line-height: 1.2;
  border: 2px solid currentColor; padding: .45rem .9rem; min-width: 6.5rem; }
.stamp:nth-child(odd) { transform: rotate(-3deg); }
.stamp:nth-child(even) { transform: rotate(2deg); }
.stamp-red { color: var(--stamp); }
.stamp-navy { color: var(--ink); }
.stamp-dashed { border-style: dashed; }
.stamp-round { border-radius: 50%; width: 7rem; height: 7rem; padding: .5rem; }
.stamp .big { font-size: 1.9rem; line-height: 1; }
.stamp .small { font-size: .7rem; font-weight: 400; }

/* ---- Buttons ---- */
.button, button.button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: 0 1.25rem;
  border-radius: 999px; border: 1px solid transparent; background: var(--stamp); color: var(--stamp-text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; }
.button:hover { filter: brightness(1.06); }
.button.button-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.button.button-navy { background: var(--navy); color: var(--on-navy); }
.button.button-dashed { background: transparent; color: var(--muted); border: 2px dashed var(--border); border-radius: 8px; }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; cursor: pointer; min-height: 44px; }
.link-button.on-navy { color: var(--on-navy); }
form.inline { display: inline; margin: 0; }

/* ---- Forms ---- */
.stacked { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label, .label { font-weight: 600; }
.hint { font-size: .9rem; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], input[type="url"], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  min-height: 44px; padding: .5rem .85rem; width: 100%; }
textarea { min-height: 6rem; resize: vertical; }
input[type="search"] { border-radius: 999px; padding: 0 1rem; }
.checkbox { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
.checkbox input { width: 1.2rem; height: 1.2rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }

/* ---- Flash messages ---- */
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-success { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--err-bg); color: var(--err-text); }
.flash-info { background: var(--info-bg); color: var(--info-text); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; position: relative; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--border); }
table.data th { font-family: var(--font-mono); font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.me td { background: var(--surface-2); font-weight: 600; }

/* ---- Sign-in: passport cover beside the form ---- */
.auth-page { display: flex; flex-wrap: wrap; gap: 1.5rem; max-width: 52rem; margin: 2rem auto; align-items: stretch; }
.auth-cover { flex: 1 1 16rem; min-height: 18rem; background: var(--cover); color: var(--gold); border-radius: 14px 6px 6px 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; padding: 2rem;
  box-shadow: inset 6px 0 0 rgba(0, 0, 0, .18); }
.auth-cover-title { font-family: var(--font-display); font-size: 2.25rem; letter-spacing: .14em; text-transform: uppercase; }
.auth-cover-sub { font-family: var(--font-mono); font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; }
.auth-form { flex: 1 1 20rem; }
@media (max-width: 640px) { .auth-cover { display: none; } .auth-page { margin-top: .5rem; } }

/* ---- Map page ---- */
.stats { margin: 0; }
.map-layout { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.map-main { flex: 999 1 560px; min-width: 0; }
.map-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 1.25rem; }
.map-side .card + .card { margin-top: 0; }
.map-card { padding: .75rem; position: relative; }
.map { height: clamp(320px, 58vh, 620px); border-radius: 8px; background: var(--sea); }
.leaflet-container { background: var(--sea); font-family: var(--font); }
.leaflet-container a { color: var(--link); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted); }
.leaflet-bar a { background: var(--surface); color: var(--text); border-bottom-color: var(--border); }
.leaflet-bar a:hover { background: var(--surface-2); }
.leaflet-tooltip.map-tip { background: var(--navy); color: var(--on-navy); border: 0; font-family: var(--font-mono); font-weight: 700; box-shadow: none; }
.leaflet-tooltip-top.map-tip::before { border-top-color: var(--navy); }
.map-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0;
  font-family: var(--font-mono); color: var(--muted); pointer-events: none; }
.map-loading[hidden] { display: none; }
.map-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; margin-top: 1rem; }
.map-tools input[type="search"] { flex: 1 1 260px; width: auto; }
.legend { display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; color: var(--muted); }
.swatch { width: 14px; height: 14px; display: inline-block; border-radius: 3px; }
.swatch-visited { background: var(--stamp); }
.swatch-shared { background: var(--ink); }
.map-main .hint { margin-top: .75rem; }

.country-panel h2 { margin: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .25rem 1rem; margin-bottom: 1rem; }
.toggle[aria-pressed="false"] { border-color: var(--stamp); color: var(--stamp); }
.country-panel .flash { margin: 1rem 0 0; }

.visited-card h3 { margin-bottom: .75rem; }
.visited-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { font: inherit; font-size: .9rem; min-height: 36px; padding: .2rem .8rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--stamp); color: var(--stamp); }
@media (max-width: 640px) {
  .page-head .stamp { min-width: 5.25rem; padding: .35rem .6rem; }
  .page-head .stamp .big { font-size: 1.5rem; }
  .map { height: 300px; }
}
@media (max-width: 520px) {
  .site-header .sign-out { display: none; } /* on the account page instead */
  .brand-word { font-size: 1.25rem; }
  .header-inner { gap: .5rem .75rem; }
  .main-nav a { padding: .5rem .8rem; }
}

/* ---- Trips as stamps, note ---- */
.panel-sub { font-family: var(--font-mono); font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 1.5rem 0 .75rem; }
.trip-stamps { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem .9rem; }
.trip-stamp { position: relative; display: flex; align-items: stretch; border: 2px solid currentColor; border-radius: 8px;
  font-family: var(--font-mono); text-transform: uppercase; }
.trip-stamp:nth-child(odd) { transform: rotate(-2deg); }
.trip-stamp:nth-child(even) { transform: rotate(2deg); }
.trip-stamp.stamp-red { color: var(--stamp); }
.trip-stamp.stamp-navy { color: var(--ink); }
.trip-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: .45rem .7rem; text-align: center; line-height: 1.25; }
.trip-main strong { font-size: 1rem; }
.trip-main .small { font-size: .7rem; letter-spacing: .08em; }
.trip-edit, .trip-delete { font: inherit; font-size: .75rem; color: inherit; background: none; border: 0; border-left: 1px dashed currentColor;
  padding: 0 .55rem; min-width: 44px; min-height: 44px; cursor: pointer; text-transform: uppercase; }
.trip-delete { font-size: 1.2rem; }
.trip-edit:hover, .trip-delete:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.trip-form { border: 1px solid var(--border); border-radius: 10px; padding: 1rem; margin: .5rem 0 1rem; background: var(--surface); }
.trip-dates { display: flex; flex-wrap: wrap; gap: .75rem; }
.trip-dates .field { flex: 1 1 9rem; }
.trip-form .hint { margin: .5rem 0 .75rem; }
.note-field { margin-top: 1.5rem; }
.note-field textarea { font-family: var(--font-mono); background: var(--surface); }

/* ---- Friends ---- */
.invite-ready { margin-bottom: 1.25rem; }
.invite-ready p { color: var(--on-navy); }
.invite-ready .hint { color: var(--gold); }
.copy-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.copy-row input { flex: 1 1 16rem; width: auto; font-family: var(--font-mono); }
.card-navy .button { background: var(--gold); color: #1b2a4a; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .button { min-height: 36px; padding: 0 .9rem; margin-right: .5rem; }
.friends-table td { vertical-align: middle; }
.plain-list { list-style: none; margin: 0 0 .75rem; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.invite-stamp { color: var(--gold); width: 10rem; height: 10rem; }
.invite-stamp strong { font-size: 1.1rem; }

/* ---- Scoreboard ---- */
.scoreboard td { vertical-align: middle; }
.scoreboard .rank { font-family: var(--font-display); font-size: 1.5rem; width: 3rem; }
.scoreboard .big-num { font-size: 1.35rem; font-weight: 700; }
.scoreboard tr.me .rank, .scoreboard tr.me .big-num { color: var(--stamp); }
.bar-col { width: 30%; min-width: 6rem; }
.bar { display: block; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--muted); border-radius: 5px; }
tr.me .bar-fill { background: var(--stamp); }
.bar-w0 { width: 0%; }
.bar-w5 { width: 5%; }
.bar-w10 { width: 10%; }
.bar-w15 { width: 15%; }
.bar-w20 { width: 20%; }
.bar-w25 { width: 25%; }
.bar-w30 { width: 30%; }
.bar-w35 { width: 35%; }
.bar-w40 { width: 40%; }
.bar-w45 { width: 45%; }
.bar-w50 { width: 50%; }
.bar-w55 { width: 55%; }
.bar-w60 { width: 60%; }
.bar-w65 { width: 65%; }
.bar-w70 { width: 70%; }
.bar-w75 { width: 75%; }
.bar-w80 { width: 80%; }
.bar-w85 { width: 85%; }
.bar-w90 { width: 90%; }
.bar-w95 { width: 95%; }
.bar-w100 { width: 100%; }
.by-continent td.leads { position: relative; font-weight: 700; color: var(--stamp); }
.by-continent td.leads::after { content: ""; position: absolute; right: .3rem; top: 50%; width: 2rem; height: 2rem; transform: translateY(-50%);
  border: 2px solid var(--stamp); border-radius: 50%; }
.champions li { border-bottom-color: rgba(255, 255, 255, .15); flex-wrap: wrap; }
.mini-board { list-style: none; margin: 0 0 .75rem; padding: 0; }
.mini-board li { display: flex; justify-content: space-between; padding: .35rem 0; }
.mini-board li.me { color: var(--gold); font-weight: 600; }
.on-navy-link { color: var(--gold); }
@media (max-width: 640px) { .scoreboard .bar-col { display: none; } .scoreboard th, .scoreboard td { padding: .55rem .4rem; } }
/* Long email addresses wrap instead of pushing the action out of the card. */
.plain-list li > span { min-width: 0; overflow-wrap: anywhere; }
.plain-list li > form { flex-shrink: 0; }

/* ---- Real passports (account page) ---- */
.passport-holder { font-family: var(--font-mono); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 1.25rem 0 .5rem; }
.passport-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.passport { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .6rem .75rem; border: 1px solid var(--border);
  border-left: 4px solid var(--status, var(--border)); border-radius: 8px; background: var(--surface); }
.passport-cover { width: 3rem; height: 4rem; flex: none; border-radius: 3px 6px 6px 3px; background: var(--cover); color: var(--gold);
  display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 700; font-size: .8rem;
  box-shadow: inset 3px 0 0 rgba(0, 0, 0, .2); }
.passport-info { display: flex; flex-direction: column; flex: 1 1 10rem; min-width: 0; line-height: 1.35; }
.passport-status { font-size: .85rem; font-weight: 600; color: var(--status-text, var(--muted)); }
.passport-actions { display: flex; align-items: center; gap: 1rem; }
.passport-ok { --status: #2f7d4f; --status-text: var(--ok-text); }
.passport-renew { --status: var(--gold); --status-text: #7a5a12; }
.passport-warn { --status: var(--stamp); --status-text: var(--err-text); }
.passport-expired { --status: var(--stamp); --status-text: var(--err-text); background: var(--err-bg); }
@media (prefers-color-scheme: dark) { .passport-renew { --status-text: var(--gold); } }
.passport-form { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px dashed var(--border); }
.passport-form h3 { margin: 0; }
.reminder-toggle .hint { margin: 1rem 0 0; } .reminder-toggle .link-button { min-height: 0; }

/* ---- Wishlist ---- */
.swatch-wish { background: var(--wish); }
.country-panel .actions-row, .country-panel #panel-toggle { margin-right: .5rem; }
.wish-toggle { margin-top: .5rem; }
.wish-toggle[aria-pressed="true"] { border-color: var(--wish); color: var(--text); background: color-mix(in srgb, var(--wish) 25%, transparent); }
.wish-toggle[aria-pressed="true"] svg { fill: var(--wish); stroke: var(--wish); }
.chip-wish { border-style: dashed; }
.chip-wish:hover { border-color: var(--wish); color: var(--text); }
.visited-card .count { font-size: .9rem; color: var(--muted); margin-left: .25rem; }
