/* Mekong design system — 1970s Cambodian psychedelic.
   Warm sunset palette (golden ochre, burnt orange, hot magenta, turquoise, grape),
   sunburst motifs, groovy uppercase headings, soft rounded shapes. Token-driven,
   dark mode via html[data-theme="dark"]. Body text stays at readable contrast. */

:root {
  /* Sunset psychedelia */
  --sun: #F2A93B;        --sun-deep: #E07A1F;
  --orange: #CC5500;     --magenta: #D6336C;   --pink: #EE6CA0;
  --teal: #16A39A;       --teal-deep: #0A615B;
  --grape: #6A4C93;      --grape-deep: #4A3068;
  --olive: #9C9A3A;

  /* Warm paper neutrals */
  --cream: #F7EAD0;      --card: #FFF6E2;      --line: #E7CFA6;
  --ink: #3A2415;        --ink-soft: #7A5A3C;

  /* Roles */
  --good: #1F7A47;       --warn: #C0431A;
  --tier-low: #1F7A47;   --tier-mid: #E07A1F;  --tier-high: #D6336C;

  /* Signature gradients */
  --grad-sun: linear-gradient(135deg, #E07A1F 0%, #E8632A 45%, #D6336C 100%);
  --grad-teal: linear-gradient(135deg, #16A39A 0%, #6A4C93 100%);
  --sunburst: repeating-conic-gradient(from 0deg at 50% 0%,
      rgba(232,99,42,0.16) 0deg 9deg, rgba(242,169,59,0.10) 9deg 18deg);

  /* Radius / spacing / type */
  --r-pill: 999px; --r-lg: 24px; --r-md: 16px; --r-sm: 10px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --fs-display: 2.2rem; --fs-h1: 1.45rem; --fs-h2: 1.18rem; --fs-h3: 1.02rem;
  --fs-lg: 1.18rem; --fs-body: 1rem; --fs-base: 1rem; --fs-sm: 0.875rem; --fs-label: 0.7rem;

  /* softer, layered shadows for a modern feel */
  --shadow: 0 12px 32px -8px rgba(120, 50, 20, 0.16), 0 2px 6px rgba(120, 50, 20, 0.06);
  --shadow-soft: 0 4px 14px -4px rgba(120, 50, 20, 0.12);
  --dur: 220ms; --ease: cubic-bezier(0.34, 0.02, 0.2, 1);

  --bg: var(--cream);
  --tabbar-h: 66px;
  --font: -apple-system, BlinkMacSystemFont, 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Avenir Next', 'Trebuchet MS', var(--font);
}

html[data-theme="dark"] {
  /* Psychedelic night: deep grape, neon accents */
  --cream: #201038; --card: #2C1A4A; --line: #4A2F6E;
  --ink: #F7E4C4; --ink-soft: #C9A9D9;
  --sun: #F6BD55; --orange: #FF7A40; --magenta: #FF5C95; --teal: #2FD0C4;
  --sunburst: repeating-conic-gradient(from 0deg at 50% 0%,
      rgba(255,122,64,0.16) 0deg 9deg, rgba(47,208,196,0.10) 9deg 18deg);
  --shadow: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-soft: 0 3px 10px rgba(0,0,0,0.4);
}

/* ---- Named visual themes (skins) — chosen in Settings -----------------------
   Each redefines the palette leaves; components stay token-driven so they reskin
   for free. Placed after the dark block so night (which rides data-theme=dark)
   wins on shared tokens. */
:root[data-skin="night"] {
  --cream: #141017; --bg: #141017; --card: #1E1822; --line: #332A3C;
  --ink: #F3EEE6; --ink-soft: #A79C8C;
  --sun: #F5A524; --sun-deep: #E08A10; --orange: #F5A524; --magenta: #FF5C8A; --pink: #FF5C8A;
  --teal: #2ED3B7; --teal-deep: #2ED3B7; --grape: #8A6BC0;
  --grad-sun: linear-gradient(135deg, #F5A524 0%, #FF5C8A 100%);
  --grad-teal: linear-gradient(135deg, #2ED3B7 0%, #8A6BC0 100%);
  --sunburst: repeating-conic-gradient(from 0deg at 50% 0%,
      rgba(245,165,36,0.10) 0deg 9deg, rgba(255,92,138,0.06) 9deg 18deg);
  --shadow-soft: 0 4px 16px -4px rgba(0,0,0,0.6);
}
:root[data-skin="silk"] {
  --cream: #F3F1EC; --bg: #F3F1EC; --card: #FFFFFF; --line: #E3DED2;
  --ink: #222019; --ink-soft: #6B635A;
  --sun: #0E7C66; --sun-deep: #0A5E4D; --orange: #0E7C66; --magenta: #E24E1B; --pink: #E24E1B;
  --teal: #0E7C66; --teal-deep: #1B4038; --grape: #6A4C93;
  --grad-sun: linear-gradient(135deg, #0E7C66 0%, #1B4038 100%);
  --grad-teal: linear-gradient(135deg, #0E7C66 0%, #1B4038 100%);
  --sunburst: repeating-conic-gradient(from 0deg at 50% 0%,
      rgba(14,124,102,0.06) 0deg 10deg, rgba(226,78,27,0.04) 10deg 20deg);
  --shadow-soft: 0 4px 14px -6px rgba(30,60,50,0.16);
}
:root[data-skin="tropical"] {
  --cream: #FBFBF9; --bg: #FBFBF9; --card: #FFFFFF; --line: #E7EDEA;
  --ink: #212529; --ink-soft: #66707A;
  --sun: #12B886; --sun-deep: #0CA678; --orange: #0E7C66; --magenta: #FF6B6B; --pink: #FF922B;
  --teal: #1098AD; --teal-deep: #0B7285; --grape: #7048E8;
  --grad-sun: linear-gradient(135deg, #12B886 0%, #1098AD 100%);
  --grad-teal: linear-gradient(135deg, #1098AD 0%, #7048E8 100%);
  --sunburst: repeating-conic-gradient(from 0deg at 50% 0%,
      rgba(18,184,134,0.08) 0deg 9deg, rgba(255,146,43,0.05) 9deg 18deg);
  --r-lg: 22px; --shadow-soft: 0 6px 18px -8px rgba(18,184,134,0.30);
}
:root[data-skin="psych"] {
  /* 1960s–70s Cambodian rock: vintage sleeve paper + swirling saturated warmth. */
  --cream: #F6E7C4; --bg: #F6E7C4; --card: #FFF4D6; --line: #E3C98C;
  --ink: #3A2410; --ink-soft: #7A5A2C;
  --sun: #E8A33D; --sun-deep: #D9541E; --orange: #C43E12; --magenta: #D6336C; --pink: #E84C88;
  --teal: #1FA6A0; --teal-deep: #0E6E68; --grape: #7B3FA0;
  --grad-sun: linear-gradient(135deg, #D9541E 0%, #D6336C 50%, #7B3FA0 100%);
  --grad-teal: linear-gradient(135deg, #1FA6A0 0%, #7B3FA0 100%);
  --sunburst: repeating-conic-gradient(from 0deg at 50% 0%,
      rgba(217,84,30,0.18) 0deg 8deg, rgba(232,163,61,0.12) 8deg 16deg, rgba(214,51,108,0.13) 16deg 24deg);
  --shadow-soft: 0 5px 16px -6px rgba(120,50,20,0.22);
}
:root[data-skin="psychnight"] {
  /* Cambodian psych as a black-light poster: near-black ground, electric neons. */
  --cream: #120A1C; --bg: #120A1C; --card: #1C1030; --line: #3A2258;
  --ink: #F6E9C9; --ink-soft: #C9A9D9;
  --sun: #FF6A2B; --sun-deep: #E24E1B; --orange: #FF3D9A; --magenta: #FF3D9A; --pink: #FF6A2B;
  --teal: #26E0C8; --teal-deep: #26E0C8; --grape: #B15CFF;
  --grad-sun: linear-gradient(135deg, #F0561A 0%, #FF3D9A 50%, #B15CFF 100%);
  --grad-teal: linear-gradient(135deg, #26E0C8 0%, #B15CFF 100%);
  --sunburst: repeating-conic-gradient(from 0deg at 50% 0%,
      rgba(255,61,154,0.16) 0deg 8deg, rgba(38,224,200,0.10) 8deg 16deg, rgba(255,106,43,0.12) 16deg 24deg);
  --shadow-soft: 0 4px 16px -4px rgba(0,0,0,0.7);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: var(--fs-body); color: var(--ink);
  background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
html[data-reduced-motion="on"] *, html[data-reduced-motion="on"] *::before {
  animation: none !important; transition: none !important;
}

#app { max-width: 720px; margin: 0 auto; min-height: 100vh; position: relative; }
.screen { padding: var(--sp-4) var(--sp-4) calc(var(--tabbar-h) + var(--sp-6)); position: relative; z-index: 1; }

h2, h3, .cat-title, .topbar h1 { font-family: var(--font-display); }

/* --- splash --- */
.splash { display: grid; place-content: center; min-height: 80vh; text-align: center; background: var(--sunburst); }
.splash-logo-svg { width: min(80vw, 330px); height: auto; }
.splash-sub { color: var(--ink-soft); }
.logo-wrap { text-align: center; }
.logo { width: min(72vw, 300px); height: auto; display: block; margin: 0 auto var(--sp-1); }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3); background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: var(--fs-h1); margin: 0; flex: 1; text-transform: uppercase; letter-spacing: 0.03em; color: var(--orange); }
.topbar .back {
  border: none; background: var(--teal); color: #fff; cursor: pointer;
  border-radius: var(--r-pill); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); font-weight: 700;
}
.topbar .back:hover { filter: brightness(1.08); }
.topbar-ic {
  border: none; background: transparent; cursor: pointer; color: var(--ink-soft);
  line-height: 1; padding: var(--sp-1) var(--sp-1); border-radius: var(--r-pill); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.topbar-ic svg { width: 22px; height: 22px; display: block; }
.topbar-ic:hover { background: rgba(128, 128, 128, 0.14); color: var(--orange); }
.topbar-sos {
  border: none; background: transparent; cursor: pointer; font-size: var(--fs-h2);
  line-height: 1; padding: var(--sp-1) var(--sp-2); border-radius: var(--r-pill); flex: none;
}
.topbar-sos:hover { background: rgba(214, 51, 108, 0.16); }
.rn-wx-link {
  border: none; background: none; padding: 0; cursor: pointer; font: inherit;
  color: var(--teal); font-weight: 700; text-decoration: underline; text-underline-offset: 2px;
}
.rn-wx-link:hover { filter: brightness(1.1); }
.filters-collapse { margin: 4px 0 10px; }
.filters-collapse > summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: var(--sp-2);
  font-weight: 700; font-size: var(--fs-sm); color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: var(--sp-2) var(--sp-4); user-select: none;
}
.filters-collapse > summary::-webkit-details-marker { display: none; }
.filters-collapse > summary::after { content: '▾'; color: var(--ink-soft); font-size: var(--fs-label); }
.filters-collapse[open] > summary::after { content: '▴'; }
.filters-collapse > summary:hover { filter: brightness(0.98); }
.filters-collapse > div { margin-top: var(--sp-2); }

/* --- cards & buttons --- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--sp-4); box-shadow: var(--shadow-soft); margin-bottom: var(--sp-3);
}
.card h2 { font-size: var(--fs-h2); margin: 0 0 var(--sp-2); }
.card h3 { font-size: var(--fs-h3); margin: var(--sp-3) 0 var(--sp-1); color: var(--teal-deep); }
html[data-theme="dark"] .card h3 { color: var(--teal); }
.muted { color: var(--ink-soft); font-size: var(--fs-sm); }
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer;
  border: none; border-radius: var(--r-pill); padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-body); font-weight: 700; font-family: inherit;
  background: var(--grad-sun); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); box-shadow: var(--shadow-soft);
  transition: filter var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn.ghost { background: none; color: var(--teal-deep); border: 2px solid var(--teal); box-shadow: none; }
html[data-theme="dark"] .btn.ghost { color: var(--teal); }
.btn.ghost:hover { background: rgba(22,163,154,0.1); }
.btn.block { display: flex; width: 100%; justify-content: center; }

/* --- home hero: psychedelic 60s/70s SE-Asia sunset --- */
.hero {
  position: relative; overflow: hidden; text-align: center; isolation: isolate;
  padding: calc(var(--sp-6) + 30px) var(--sp-4) var(--sp-5);
  margin: calc(-1 * var(--sp-4)) calc(-1 * var(--sp-4)) var(--sp-5);
  border-radius: 0 0 34px 34px; box-shadow: var(--shadow-soft);
  background:
    radial-gradient(125% 100% at 50% -12%, rgba(242,169,59,0.55) 0%, rgba(232,99,42,0.34) 34%, rgba(214,51,108,0.20) 58%, rgba(106,76,147,0.10) 100%),
    repeating-conic-gradient(from 0deg at 50% -2%, rgba(232,99,42,0.16) 0deg 7deg, rgba(242,169,59,0) 7deg 14deg),
    var(--card);
}
/* warm glowing sun rising behind the wordmark */
.hero::before {
  content: ''; position: absolute; z-index: -1; top: -86px; left: 50%; transform: translateX(-50%);
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, #FFEFC2 0%, #F2A93B 42%, rgba(232,99,42,0) 70%); opacity: 0.85;
}
.hero .logo { width: min(74vw, 320px); }
.hero h1 { font-family: var(--font-display); font-size: var(--fs-display); margin: 0 0 var(--sp-1);
  background: var(--grad-sun); -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: 0.05em; }
.hero p { color: var(--ink); margin: var(--sp-2) 0 0; font-weight: 700; font-size: var(--fs-h3); opacity: 0.86; }

.home-actions { display: flex; gap: var(--sp-2); justify-content: center; flex-wrap: wrap; margin-bottom: var(--sp-5); }
.home-section { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.08em;
  font-size: var(--fs-sm); color: var(--orange); margin: 0 0 var(--sp-2); font-weight: 800; }
.home-group { text-transform: uppercase; letter-spacing: 0.06em; font-size: var(--fs-label);
  color: var(--ink-soft); font-weight: 700; margin: var(--sp-4) 0 var(--sp-2); }
.home-group:first-of-type { margin-top: var(--sp-2); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.tile {
  display: flex; flex-direction: column; gap: var(--sp-1); text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--sp-4); box-shadow: var(--shadow-soft); font-family: inherit; color: var(--ink);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--orange); }
/* soft tinted disc behind each tile icon for visual rhythm (purely decorative) */
.tile .ic { font-size: 1.55rem; width: 48px; height: 48px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; margin-bottom: 2px;
  background: linear-gradient(135deg, rgba(242,169,59,0.24), rgba(232,99,42,0.12)); }
html[data-theme="dark"] .tile .ic { background: linear-gradient(135deg, rgba(242,169,59,0.22), rgba(214,51,108,0.20)); }
.tile:hover .ic { background: linear-gradient(135deg, rgba(242,169,59,0.34), rgba(232,99,42,0.20)); }
.tile .t { font-weight: 800; font-size: var(--fs-h3); }
.tile .d { color: var(--ink-soft); font-size: var(--fs-sm); }

.country-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.country-chip {
  display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-family: inherit;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); min-height: 44px;
  border-radius: var(--r-pill); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); font-weight: 700;
}
.country-chip[aria-pressed="true"] { background: var(--grad-sun); color: #fff; border-color: transparent; }
.country-chip .flag { font-size: 1.1rem; }

/* --- chips / filters --- */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-2) 0 var(--sp-4); }
.chip {
  cursor: pointer; font-family: inherit; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); border-radius: var(--r-pill); padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
}
.chip[aria-pressed="true"] { background: var(--teal-deep); border-color: transparent; color: #fff; }

.search {
  width: 100%; font-family: inherit; font-size: var(--fs-body); color: var(--ink);
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r-pill);
  padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-3);
}
.search:focus { outline: none; border-color: var(--orange); }

/* --- phrasebook --- */
.lang-tabs { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.cat-title { font-size: var(--fs-h3); color: var(--magenta); margin: var(--sp-4) 0 var(--sp-2);
  text-transform: uppercase; letter-spacing: 0.04em; }
.phrase {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0;
  border-bottom: 1px dashed var(--line);
}
.phrase .en { font-weight: 800; }
.phrase .native { font-size: 1.2rem; color: var(--grape); }
html[data-theme="dark"] .phrase .native { color: var(--pink); }
.phrase .roman { color: var(--ink-soft); font-size: var(--fs-sm); font-style: italic; }
.phrase .note { color: var(--ink-soft); font-size: var(--fs-sm); }
.phrase .grow { flex: 1; min-width: 0; }
.lbl { font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); opacity: 0.7; margin-right: var(--sp-1); }
.speak {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--grad-teal); color: #fff; font-size: 1.1rem;
}
.speak:hover { filter: brightness(1.08); }
.speak[disabled] { opacity: 0.3; cursor: not-allowed; filter: grayscale(1); }
.phrase-ctrls { flex: none; display: flex; gap: var(--sp-1); align-items: center; }
.phrase .grow.tappable { cursor: pointer; border-radius: var(--r-2); }
.phrase .grow.tappable:hover { background: rgba(0,0,0,0.03); }
.phrase .grow.tappable:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* "Show to a local": full-screen, very large native script */
.bigphrase {
  position: fixed; inset: 0; z-index: 200; background: var(--cream);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.bigphrase-inner { max-width: 92vw; text-align: center; }
.bp-en { font-size: 1.1rem; color: var(--ink-soft); margin-bottom: 16px; }
.bp-script { font-size: 13vw; line-height: 1.18; color: var(--ink); font-weight: 800; word-break: break-word; }
.bp-roman { font-size: 1.6rem; color: var(--teal-deep); margin-top: 16px; font-style: italic; }
html[data-theme="dark"] .bp-roman { color: var(--teal); }
.bp-note { font-size: 1rem; color: var(--ink-soft); margin-top: 12px; }
.bp-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }

/* Map city markers: a count bubble at region zoom, a small place-name label zoomed in */
.linklike { background: none; border: none; padding: 0; color: var(--teal-deep); font: inherit; text-decoration: underline; cursor: pointer; }
html[data-theme="dark"] .linklike { color: var(--teal); }
.mk-city { font-family: var(--font-ui, system-ui, sans-serif); font-weight: 700; white-space: nowrap; user-select: none; line-height: 1; }
.mk-city.bubble { color: #fff; background: var(--teal-deep); padding: 4px 9px; border-radius: 999px;
  font-size: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.5); }
.mk-city.label { color: var(--ink); background: transparent; font-size: 11px; font-weight: 800;
  text-shadow: 0 0 3px var(--card), 0 0 4px var(--card), 0 0 4px var(--card); }
html[data-theme="dark"] .mk-city.label { color: #fff; text-shadow: 0 0 3px #000, 0 0 4px #000; }
.banner {
  background: linear-gradient(135deg, rgba(242,169,59,0.22), rgba(214,51,108,0.16));
  border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); margin-bottom: var(--sp-3);
}

/* --- places --- */
.tier { font-size: var(--fs-label); font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
        padding: 3px var(--sp-2); border-radius: var(--r-pill); color: #fff; }
.tier.low { background: var(--tier-low); }
.tier.mid { background: var(--tier-mid); }
.tier.high { background: var(--tier-high); }
.tier.any { background: var(--grape); }
.cats { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.cat-tag { font-size: var(--fs-label); color: #fff; background: var(--teal-deep);
           border-radius: var(--r-pill); padding: 3px var(--sp-2); text-transform: capitalize; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.place-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-2); }
.save-star { border: none; background: none; cursor: pointer; font-size: 1.5rem; color: var(--sun-deep); line-height: 1; }

.list-note { display: flex; gap: var(--sp-2); padding: var(--sp-2) 0; }
.list-note::before { content: "✷"; color: var(--orange); }
.warn-note { display: flex; gap: var(--sp-2); padding: var(--sp-2) 0; color: var(--warn); font-weight: 600; }
.warn-note::before { content: "⚠"; }

/* --- prices --- */
.price-item { padding: var(--sp-3) 0; border-bottom: 1px dashed var(--line); }
.price-item .fair { font-weight: 800; color: var(--teal-deep); }
html[data-theme="dark"] .price-item .fair { color: var(--teal); }
.price-item .better { color: var(--good); font-size: var(--fs-sm); }
.price-item .scam { color: var(--warn); font-size: var(--fs-sm); }

/* --- routes --- */
.route-opt { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3);
             margin-top: var(--sp-2); background: var(--card); }
.route-opt.best { border-color: var(--orange); background: linear-gradient(135deg, rgba(242,169,59,0.18), rgba(232,99,42,0.10)); }
.route-opt .mode { font-weight: 800; }
.pill-best { font-size: var(--fs-label); font-weight: 800; background: var(--grad-sun); color: #fff;
             border-radius: var(--r-pill); padding: 3px var(--sp-2); text-transform: uppercase; }
.border-flag { font-size: var(--fs-sm); color: var(--magenta); font-weight: 700; }
/* --- journey planner --- */
.plan-picker { display: flex; flex-direction: column; gap: var(--sp-2); }
.plan-field { display: flex; flex-direction: column; gap: 4px; }
.plan-field .lbl { font-size: var(--fs-label); font-weight: 800; text-transform: uppercase; color: var(--ink-soft); letter-spacing: 0.04em; }
.plan-picker select { width: 100%; min-height: 44px; font-family: inherit; font-size: var(--fs-base); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); background: var(--card); color: var(--ink); }
.swap-btn { min-height: 40px; }
.plan-chain { font-weight: 800; color: var(--teal-deep); line-height: 1.4; }
.plan-leg { border-left: 3px solid var(--teal); padding: var(--sp-2) 0 var(--sp-2) var(--sp-3); margin-top: var(--sp-3); }
.plan-leg-head { font-weight: 800; margin-bottom: 2px; }
.sos-loc { background: var(--card); border-left: 3px solid var(--magenta); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); font-weight: 600; margin: 0 0 var(--sp-3); }
/* --- context-aware "right now" home feed --- */
.net-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 10px; padding: 8px 12px; border-radius: var(--r-md, 12px); background: var(--card); border: 1px solid var(--line); }
.welcome .card h2 { margin-top: 0; }
.access-focus { border-left: 4px solid var(--teal); }
.right-now { border-top: 4px solid var(--teal); }
.rn-head { display: flex; align-items: center; gap: var(--sp-3); }
.rn-emoji { font-size: 30px; line-height: 1; }
.rn-title { font-weight: 800; font-size: var(--fs-lg); color: var(--ink); }
.rn-sub { font-size: var(--fs-sm); }
.rn-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.rn-item { width: 100%; text-align: left; cursor: pointer; font-family: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); }
.rn-item:active { transform: scale(0.99); }
.rn-item-main { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.rn-name { font-weight: 700; }
.rn-tag { flex: none; font-size: var(--fs-label); font-weight: 800; color: #fff; background: var(--teal-deep); border-radius: var(--r-pill); padding: 2px 8px; }
.rn-meta { font-size: var(--fs-sm); margin-top: 2px; }
.rn-events { display: flex; flex-direction: column; gap: var(--sp-2); margin: var(--sp-2) 0; }
.rn-event { width: 100%; text-align: left; cursor: pointer; font-family: inherit; color: var(--ink); background: linear-gradient(135deg, rgba(242,169,59,0.16), rgba(214,51,108,0.10)); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }
.rn-event-when { font-weight: 800; color: var(--magenta); }
/* --- history & orientation --- */
.history-card { border-left: 4px solid var(--gold, var(--orange)); }
.knownfor { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--sp-2) 0; }
.kf-tag { font-size: var(--fs-label); font-weight: 700; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px 10px; }
.culture-tip { font-size: var(--fs-sm); color: var(--ink-soft); margin: var(--sp-2) 0 0; }

/* --- info accordion --- */
.acc { border-bottom: 1px dashed var(--line); }
.acc summary { cursor: pointer; padding: var(--sp-3) 0; font-weight: 700; font-size: var(--fs-h3); list-style: none; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: "✸"; float: right; color: var(--orange); }
.acc[open] summary::after { content: "✷"; }
.acc p { margin: var(--sp-1) 0; }

/* --- settings form --- */
.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-weight: 700; margin-bottom: var(--sp-1); }
.field input, .field select {
  width: 100%; font-family: inherit; font-size: var(--fs-body); color: var(--ink);
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r-md); padding: var(--sp-3);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--orange); }

/* --- your notes & review --- */
.ta {
  width: 100%; min-height: 80px; font-family: inherit; font-size: var(--fs-body); color: var(--ink);
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r-md); padding: var(--sp-3); resize: vertical;
}
.ta:focus { outline: none; border-color: var(--orange); }
.stars { display: flex; gap: var(--sp-1); }
.star { border: none; background: none; cursor: pointer; font-size: 1.7rem; color: var(--sun-deep); line-height: 1; padding: 0; }
.review-orig, .review-yours { border-left: 4px solid var(--teal); padding: var(--sp-2) var(--sp-3); margin: var(--sp-3) 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; background: rgba(22,163,154,0.08); }
.review-yours { border-left-color: var(--coral, #E8632A); background: rgba(232,99,42,0.09); }
.rlabel { display: inline-block; font-size: var(--fs-label); font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--teal-deep); margin-bottom: var(--sp-1); }
.review-yours .rlabel { color: var(--orange); }
html[data-theme="dark"] .review-orig .rlabel { color: var(--teal); }

/* --- travel journal (antique book) --- */
.book.closed {
  display: block; width: 230px; height: 310px; margin: var(--sp-5) auto; cursor: pointer;
  position: relative; border: none; padding: 0; border-radius: 6px 12px 12px 6px;
  background: linear-gradient(135deg, #6B3415 0%, #46210C 60%, #2F1607 100%);
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(217,162,62,0.5), inset 0 0 0 8px rgba(217,162,62,0.12);
  transition: transform var(--dur) var(--ease);
}
.book.closed:hover { transform: translateY(-3px) rotate(-0.5deg); }
.book-spine { position: absolute; left: 0; top: 0; bottom: 0; width: 14px; border-radius: 6px 0 0 6px;
  background: linear-gradient(90deg, rgba(0,0,0,0.35), transparent); }
.book-cover { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2); color: #F0CE84; text-align: center; padding: var(--sp-4); }
.book-emboss { font-size: var(--fs-label); letter-spacing: 0.22em; opacity: 0.85; }
.book-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; line-height: 1.15;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4); }
.book-flour { color: #D9A23E; letter-spacing: 0.3em; }
.book-count { margin-top: var(--sp-4); font-size: var(--fs-sm); opacity: 0.8; text-transform: uppercase; letter-spacing: 0.12em; }

.book-open { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; border-radius: var(--r-md); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--line); }
@media (max-width: 520px) { .book-open { grid-template-columns: 1fr; } }
.page { background:
    repeating-linear-gradient(transparent, transparent 27px, rgba(120,90,50,0.12) 28px),
    linear-gradient(180deg, #FBF1DA, #F4E6C8); color: #4A3520; padding: var(--sp-5) var(--sp-4); min-height: 260px; }
.page-left { background-image: repeating-linear-gradient(transparent, transparent 27px, rgba(120,90,50,0.12) 28px), linear-gradient(90deg, #EFDFBE, #FBF1DA); text-align: center; }
.page-single { border: 1px solid var(--line); border-radius: var(--r-md); }
.page-enter { animation: pageIn var(--dur) var(--ease); transform-origin: left center; }
@keyframes pageIn { from { transform: rotateY(-14deg); opacity: 0.5; } to { transform: rotateY(0); opacity: 1; } }
.page-head { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.08em; color: #8A5A2A; font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.page-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; color: #5A3A18; }
.toc { margin: 0; padding-left: var(--sp-5); }
.toc li { margin: var(--sp-2) 0; }
.toc-link { border: none; background: none; cursor: pointer; font-family: inherit; color: #5A3A18; text-align: left; font-size: var(--fs-body); padding: 0; }
.toc-link:hover { text-decoration: underline; }
.toc-date { font-size: var(--fs-label); color: #8A5A2A; }
.stamp { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-sm); color: #8A5A2A; border-bottom: 1px dashed rgba(120,90,50,0.4); padding-bottom: var(--sp-2); margin-bottom: var(--sp-3); letter-spacing: 0.02em; }
.entry-title { font-family: var(--font-display); color: #5A3A18; margin: 0 0 var(--sp-2); }
.entry-body p { margin: 0 0 var(--sp-3); }

.journey-wrap { display: flex; justify-content: center; margin-bottom: var(--sp-3); }
.journey-svg { width: 100%; max-width: 360px; background: var(--sunburst), var(--card); border-radius: var(--r-lg); }
.stars-static { color: var(--sun-deep); font-size: 1.1rem; letter-spacing: 1px; }
.rating-block { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-2) 0; }
.rev-link { font-size: var(--fs-sm); font-weight: 700; }
.src-link { color: var(--teal-deep); text-decoration: underline; font-style: normal; }

/* --- nature field guide --- */
.species-card { display: flex; align-items: center; gap: var(--sp-3); width: 100%; text-align: left; cursor: pointer; font-family: inherit; color: var(--ink); }
.species-emoji { font-size: 1.9rem; line-height: 1; flex: none; }
.species-emoji.big { font-size: 2.6rem; }
.species-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.sci { font-style: italic; color: var(--ink-soft); font-size: var(--fs-sm); }

/* --- bottom tab bar --- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: var(--tabbar-h);
  display: flex; max-width: 720px; margin: 0 auto;
  background: var(--card); border-top: 3px solid transparent;
  border-image: var(--grad-sun) 1; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: none; background: none; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-soft); font-size: var(--fs-label); font-weight: 700;
}
.tabbar button .ic { font-size: 1.3rem; display: block; }
.tabbar button .ic svg { width: 26px; height: 26px; display: block; }
.tabbar button[aria-current="page"] { color: var(--orange); }

/* --- save sheet (modal) --- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(58,36,21,0.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 720px; max-height: 82vh; overflow-y: auto;
  background: var(--card); border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-top: 4px solid transparent; border-image: var(--grad-sun) 1;
  padding: var(--sp-5) var(--sp-4) var(--sp-6); box-shadow: var(--shadow);
}
.sheet h3 { font-family: var(--font-display); margin: 0 0 var(--sp-3); color: var(--orange); text-transform: uppercase; letter-spacing: 0.03em; }
.coll-row {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0;
  border-bottom: 1px dashed var(--line); cursor: pointer; font-weight: 600;
}
.coll-row input { width: 22px; height: 22px; accent-color: var(--orange); }

/* --- country-picker region map (offline SVG, clickable) --- */
.region-map {
  position: relative; margin-bottom: var(--sp-4);
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow-soft);
  /* Sea fills the card; the SVG is transparent and the countries float on it, so the
     letterboxing from the tall map blends seamlessly. */
  background: radial-gradient(125% 95% at 50% 36%, #C7E9E4 0%, #7FC3BD 100%);
}
/* Capped, responsive height keeps the map compact on a phone instead of dominating
   the screen; the map scales to fit and centres. */
.region-svg { display: block; width: 100%; height: clamp(230px, 40vh, 380px); }
.ctry-group { cursor: pointer; }
.ctry {
  stroke: #FFFDF5; stroke-width: 2.5; stroke-linejoin: round;
  transform-box: fill-box; transform-origin: center;
  transition: filter var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.ctry-group:hover .ctry,
.ctry-group:focus-visible .ctry {
  filter: brightness(1.1) drop-shadow(0 3px 7px rgba(0,0,0,0.28));
  transform: translateY(-2px);
}
.ctry-group:focus { outline: none; }
.ctry-group:focus-visible .ctry { stroke-width: 4; }
.ctry-label { pointer-events: none; }
/* the Mekong River, drawn over the country fills and under the labels */
.mekong-group { pointer-events: none; }
.mekong-casing { fill: none; stroke: #FFFDF5; stroke-width: 8.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.55; }
.mekong { fill: none; stroke: #2C7DA0; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.mekong-name { font-family: var(--font-display); font-weight: 800; font-size: 21px; letter-spacing: 3px;
  fill: #1B5C7A; paint-order: stroke; stroke: rgba(255,253,245,0.92); stroke-width: 4px; stroke-linejoin: round; }
.ctry-flag { font-size: 52px; }
.ctry-name {
  font-family: inherit; font-weight: 800; font-size: 34px; fill: #fff;
  paint-order: stroke; stroke: rgba(0,0,0,0.4); stroke-width: 5px; stroke-linejoin: round;
  letter-spacing: 0.02em;
}
.region-cap {
  display: block; text-align: center; padding: var(--sp-2);
  font-size: var(--fs-label); color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.06em; background: var(--card);
}

.fx-result { font-weight: 800; font-size: var(--fs-h2); color: var(--teal-deep); margin-top: var(--sp-3); }
html[data-theme="dark"] .fx-result { color: var(--teal); }

/* --- map --- */
#map-canvas {
  width: 100%; height: 62vh; min-height: 360px; border-radius: var(--r-lg);
  border: 1px solid var(--line); overflow: hidden; margin-bottom: var(--sp-3); background: var(--card);
}
.map-toolbar { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.map-hint { font-size: var(--fs-sm); color: var(--ink-soft); margin: 0 0 var(--sp-2); }
.maplibregl-ctrl-group { border-radius: var(--r-md) !important; }

/* offline map search */
.map-search-wrap { margin-bottom: var(--sp-2); }
.map-search { width: 100%; padding: 10px 14px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r-pill); }
.map-search:focus { outline: none; border-color: var(--orange); }
.map-search-results:not(:empty) { margin-top: var(--sp-1); max-height: 230px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); padding: 6px; }
.btn.toggle-on { background: var(--teal); color: #fff; border-color: var(--teal); }

/* map key (legend): pins + every line, grouped and swatched */
.map-key summary { font-weight: 800; cursor: pointer; color: var(--teal-deep); list-style: none; }
.map-key summary::-webkit-details-marker { display: none; }
.map-key summary::before { content: "▸ "; color: var(--orange); }
.map-key[open] summary::before { content: "▾ "; }
html[data-theme="dark"] .map-key summary { color: var(--teal); }
.key-subhead { font-weight: 800; color: var(--orange); font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.05em; margin: 12px 0 5px; }
.key-grid { display: flex; flex-wrap: wrap; gap: 7px 18px; }
.key-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.line-swatch { display: inline-flex; align-items: center; flex: 0 0 auto; }
.key-label { font-weight: 600; }
.key-sub { color: var(--ink-soft); }
.key-note { font-size: 12px; color: var(--ink-soft); margin: 6px 0 0; }
/* ring round each key dot so low-luminance fills keep a visible edge on both cards */
:root { --key-dot-ring: rgba(0, 0, 0, 0.45); }
html[data-theme="dark"] { --key-dot-ring: rgba(255, 255, 255, 0.45); }

/* perf: skip rendering offscreen cards/rows in long lists */
.card, .species-card, .phrase, .price-item { content-visibility: auto; contain-intrinsic-size: auto 90px; }

/* home quick actions (search + emergency) */
.home-actions { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.home-actions .btn { flex: 1; justify-content: center; }

/* global search results */
.srch { justify-content: flex-start; text-align: left; margin-bottom: var(--sp-2); }

/* emergency / SOS */
.sos-card { border-color: var(--coral); }
.sos-num { background: var(--coral); font-size: 1.05rem; margin-bottom: var(--sp-2); }

/* accessibility: text size scales the rem-based type */
html[data-text="s"] { font-size: 15px; }
html[data-text="l"] { font-size: 18.5px; }

/* pre-trip checklist */
.ck-row { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-1); border-bottom: 1px dashed var(--line); cursor: pointer; }
.ck-row input { width: 22px; height: 22px; accent-color: var(--orange); flex: none; margin-top: 2px; }
.ck-row.done { opacity: 0.55; }
.ck-row.done strong { text-decoration: line-through; }

/* trip planner + journal photo */
.bestof-card { width: 100%; text-align: left; cursor: pointer; font-family: inherit; color: var(--ink); }
.trip-stop { padding: var(--sp-2) 0; border-bottom: 1px dashed var(--line); }
.entry-photo { width: 100%; border-radius: var(--r-md); margin: var(--sp-2) 0; display: block; border: 1px solid var(--line); }

.empty { text-align: center; color: var(--ink-soft); padding: var(--sp-6) var(--sp-4); }
.disclaimer { font-size: var(--fs-sm); color: var(--ink-soft); font-style: italic; margin-top: var(--sp-3); }
a { color: var(--teal-deep); }
html[data-theme="dark"] a { color: var(--teal); }

/* Identify photos — self-hosted, openly licensed; a placeholder slot shows until
   the real image is bundled (photos are filled in a dedicated pass). */
.id-photo { margin: var(--sp-2) 0; }
.id-photo img { width: 100%; height: auto; display: block; border-radius: var(--r-md); border: 1px solid var(--line); }
.id-photo figcaption { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: var(--sp-1, 4px); }
.id-photo.placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 132px; background: var(--card-2, rgba(0, 0, 0, 0.04)); border: 1px dashed var(--line); border-radius: var(--r-md); color: var(--ink-soft); }
.id-photo .id-photo-emoji { font-size: 2.4rem; line-height: 1; }

/* Visible keyboard focus ring on every interactive control (WCAG 2.4.7). */
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--ink); outline-offset: 2px; border-radius: var(--r-sm);
}
.search:focus-visible, .field input:focus-visible, .field select:focus-visible, .ta:focus-visible {
  outline: 3px solid var(--orange); outline-offset: 1px;
}
html[data-theme="dark"] a:focus-visible, html[data-theme="dark"] button:focus-visible,
html[data-theme="dark"] summary:focus-visible, html[data-theme="dark"] [tabindex]:focus-visible { outline-color: var(--sun); }

/* Travel circle (backendless share / connect / message) */
.tiny { font-size: var(--fs-sm); }
.avatar { font-size: 1.55rem; width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--card-2, rgba(0, 0, 0, 0.05)); border: 1px solid var(--line); flex: 0 0 auto; }
.contact-row { padding: var(--sp-2, 8px) 0; border-top: 1px solid var(--line); gap: 10px; }
.contact-row:first-of-type { border-top: 0; }
.contact-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.contact-id strong { display: block; }
.contact-id .tiny { overflow-wrap: anywhere; }
.thread { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 82%; padding: 8px 12px; border-radius: 14px; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--card-2, rgba(0, 0, 0, 0.06)); border-bottom-left-radius: 4px; }
.bubble .who { font-size: var(--fs-sm); opacity: 0.75; display: block; margin-bottom: 2px; }

/* Local noticeboard */
.board-row { padding: var(--sp-2, 8px) 0; border-top: 1px dashed var(--line); }
.board-row:first-of-type { border-top: 0; }
.board-post { padding: var(--sp-2, 8px) 0; border-top: 1px solid var(--line); }
.board-post:first-of-type { border-top: 0; }

/* ============================================================================
   DESIGN REFRESH v2 — expert polish layer (2026-07, mk-v0.93.0)
   Additive, token-level. Fluid type, layered depth, tasteful entrance motion,
   refined micro-states. Fully honours reduced-motion. No identity change:
   the 1970s sunset palette and motifs are kept; this makes them sing.
   ========================================================================== */

:root {
  /* Fluid type — scales smoothly phone → desktop for a premium feel. */
  --fs-display: clamp(2.05rem, 1.5rem + 3.4vw, 2.95rem);
  --fs-h1: clamp(1.35rem, 1.18rem + 0.9vw, 1.6rem);
  --fs-h2: clamp(1.12rem, 1.02rem + 0.5vw, 1.28rem);

  /* Elevation tiers with a warm tint (matches the paper palette). */
  --elev-1: 0 1px 2px rgba(120,50,20,0.05), 0 3px 10px -4px rgba(120,50,20,0.12);
  --elev-2: 0 2px 5px rgba(120,50,20,0.07), 0 14px 34px -10px rgba(120,50,20,0.20);
  --elev-3: 0 4px 10px rgba(120,50,20,0.09), 0 26px 56px -14px rgba(120,50,20,0.26);
  /* Glass edge: a hairline top highlight that reads as a lit bevel. */
  --edge-hi: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0));
  --card-wash: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 46%);
  --dur-fast: 140ms;
}
html[data-theme="dark"] {
  --elev-1: 0 1px 2px rgba(0,0,0,0.4), 0 3px 10px -4px rgba(0,0,0,0.5);
  --elev-2: 0 2px 6px rgba(0,0,0,0.45), 0 16px 36px -10px rgba(0,0,0,0.6);
  --elev-3: 0 4px 12px rgba(0,0,0,0.5), 0 28px 60px -14px rgba(0,0,0,0.7);
  --edge-hi: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0));
  --card-wash: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0) 46%);
}

/* Brand-tinted selection + thin scrollbar — small touches that read as care. */
::selection { background: rgba(214,51,108,0.24); }
* { scrollbar-width: thin; scrollbar-color: var(--sun-deep) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--sun-deep); border-radius: 999px; border: 2px solid var(--bg); }

/* Display headings: tighter tracking + optical line-height for a crafted look. */
.hero h1 { line-height: 1.04; }
h2, h3, .cat-title, .topbar h1, .home-section { text-wrap: balance; }

/* --- Cards: layered depth + lit top edge + subtle top-light wash ---------- */
.card { position: relative; box-shadow: var(--elev-1); background-image: var(--card-wash); background-repeat: no-repeat; }
.card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 2px; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--edge-hi); pointer-events: none;
}

/* --- Tiles: crisper hover lift, gradient icon disc gains a ring ----------- */
.tile { position: relative; box-shadow: var(--elev-1); overflow: hidden; }
.tile::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--grad-sun); opacity: 0; transition: opacity var(--dur) var(--ease);
}
.tile:hover { box-shadow: var(--elev-2); }
.tile:hover::after { opacity: 1; }
.tile:active { transform: translateY(-1px) scale(0.995); }
.tile .ic { box-shadow: inset 0 0 0 1px rgba(232,99,42,0.18); transition: transform var(--dur) var(--ease); }
.tile:hover .ic { transform: scale(1.06) rotate(-3deg); }

/* --- Section headers: a short gradient accent bar ------------------------- */
.home-section { display: flex; align-items: center; gap: var(--sp-2); }
.home-section::before {
  content: ''; width: 22px; height: 3px; border-radius: 999px; background: var(--grad-sun); flex: none;
}

/* --- Buttons: glossy top sheen + tactile press --------------------------- */
.btn { position: relative; overflow: hidden; }
.btn:not(.ghost)::before {
  content: ''; position: absolute; inset: 0 0 50% 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0)); pointer-events: none;
}
.btn:active { transform: translateY(0) scale(0.98); filter: brightness(0.98); }

/* --- Chips: active state gets a soft glow -------------------------------- */
.chip[aria-pressed="true"], .country-chip[aria-pressed="true"] { box-shadow: 0 3px 10px -3px rgba(22,163,154,0.5); }
.country-chip[aria-pressed="true"] { box-shadow: 0 3px 12px -3px rgba(214,51,108,0.5); }
.chip, .country-chip { transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease); }
.chip:active, .country-chip:active { transform: scale(0.95); }

/* --- Bottom tab bar: active tab gains a gradient indicator + lift --------- */
.tabbar button { position: relative; transition: color var(--dur) var(--ease); }
.tabbar button .ic { transition: transform var(--dur) var(--ease); }
.tabbar button[aria-current="page"] .ic { transform: translateY(-2px); }
.tabbar button[aria-current="page"]::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 0 0 999px 999px; background: var(--grad-sun);
}

/* --- Bubbles / boards: gentle depth --------------------------------------- */
.bubble { box-shadow: var(--elev-1); }
.route-opt.best, .banner { box-shadow: var(--elev-1); }

/* --- Entrance motion: each screen's cards & tiles rise in (staggered) ------
   Runs on every screen mount (the SPA replaces #app), so navigation feels
   alive. Kept short and soft. Disabled for reduced-motion users. */
@media (prefers-reduced-motion: no-preference) {
  .screen > .card, .screen > .grid > .tile, .screen > .region-map, .screen > .banner {
    animation: riseIn 380ms var(--ease) both;
  }
  .screen > .grid > .tile:nth-child(2) { animation-delay: 40ms; }
  .screen > .grid > .tile:nth-child(3) { animation-delay: 80ms; }
  .screen > .grid > .tile:nth-child(4) { animation-delay: 120ms; }
  .screen > .grid > .tile:nth-child(5) { animation-delay: 160ms; }
  .screen > .grid > .tile:nth-child(6) { animation-delay: 200ms; }
  .screen > .grid > .tile:nth-child(n+7) { animation-delay: 240ms; }
  .screen > .card:nth-of-type(2) { animation-delay: 60ms; }
  .screen > .card:nth-of-type(3) { animation-delay: 110ms; }
  .screen > .card:nth-of-type(n+4) { animation-delay: 150ms; }
  /* Hero sun: a slow, calm breathing glow. */
  .hero::before { animation: sunGlow 9s var(--ease) infinite; }
}
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes sunGlow {
  0%, 100% { opacity: 0.78; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.95; transform: translateX(-50%) scale(1.06); }
}
/* Respect the app's own reduced-motion switch too. */
html[data-reduced-motion="on"] .screen > .card,
html[data-reduced-motion="on"] .screen > .grid > .tile,
html[data-reduced-motion="on"] .hero::before { animation: none !important; }

/* Unread badge on a home tile (e.g. Travel circle: items shared with you). */
.tile-badge {
  position: absolute; top: 10px; right: 12px; z-index: 1;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800; color: #fff; background: var(--magenta);
  box-shadow: 0 2px 6px -1px rgba(214,51,108,0.6); border: 1.5px solid var(--card);
}

/* "1.2 km · ~15 min walk · NE" from the user's last GPS fix, shown on cards + detail. */
.dist-chip {
  display: inline-block; font-size: 0.76rem; font-weight: 700; line-height: 1.5;
  color: #fff; background: var(--grape); border-radius: 999px; padding: 2px 10px;
}
/* Embedded results map on the Places screen: give the empty canvas a resting shape. */
.places-map { box-shadow: var(--elev-1); background: var(--card); }
.places-map .maplibregl-ctrl-bottom-left, .places-map .maplibregl-ctrl-bottom-right { font-size: 10px; }

/* Near-me: compact "name … distance" rows (scannable, low-scroll). */
.near-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; }
.near-row .near-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.near-row .dist-chip { flex: none; }
.arrival-item { border-top: 1px solid var(--edge-hi, rgba(0,0,0,0.08)); padding: 6px 0; }
.arrival-item summary { cursor: pointer; font-weight: 700; padding: 4px 0; }

/* Place-detail "Find it" orientation block. */
.local-name { font-size: 1.15rem; font-weight: 700; color: var(--grape); margin: 2px 0 6px; }
.recognition {
  background: rgba(30,158,90,0.10); border-left: 3px solid var(--sage, #6E9A52);
  border-radius: 8px; padding: 8px 12px; margin: 4px 0 8px; line-height: 1.45;
}
[data-theme="dark"] .recognition { background: rgba(110,154,82,0.18); }
.mini-map { box-shadow: var(--elev-1); background: var(--card); }

/* One-time "use my location" invite on Home. */
.geo-invite { border-left: 3px solid var(--grape); }

/* ---- Wave 5: visual polish — rhythm, calm surfaces, real states ------------- */
/* Display type should not ride the 1.5 body line-height; tighten heading rhythm. */
h1, h2, h3, .topbar h1, .home-section, .cat-title { line-height: 1.18; }
.card h2, .card h3 { line-height: 1.2; }
/* Empty states: constrained measure + centred so they read as intentional, not broken. */
.empty { font-size: var(--fs-sm); line-height: 1.55; max-width: 42ch; margin-inline: auto; }
/* Loading states (previously none): subtle skeleton shimmer + inline spinner. */
.skeleton { position: relative; overflow: hidden; background: var(--line);
  border-radius: var(--r-sm); min-height: 14px; }
.skeleton::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  transform: translateX(-100%); animation: mk-shimmer 1.3s infinite; }
@keyframes mk-shimmer { 100% { transform: translateX(100%); } }
.spinner { display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em;
  margin-right: 0.4em; border: 2px solid var(--line); border-top-color: var(--teal);
  border-radius: 50%; animation: mk-spin 0.7s linear infinite; }
@keyframes mk-spin { 100% { transform: rotate(360deg); } }
html[data-reduced-motion="on"] .skeleton::after,
html[data-reduced-motion="on"] .spinner { animation: none; }
/* The active tab lifts a touch so the current section is unmistakable. */
.tabbar button[aria-current="page"] { font-weight: 800; }
.tabbar button[aria-current="page"] .ic { transform: translateY(-1px) scale(1.08); }
