
  :root {
    color-scheme: dark light;
    --bg: #0e1420; --panel: #151c2a; --panel-2: #1d2636; --border: #263244;
    --text: #f5f7fa; --muted: #a3b1c5; --accent: #4c97e8; --on-accent: #0e1420;
    --been: #4c97e8; --lived: #8e74fa; --want: #f2b85c; --unvisited: #3a4451;
    --been-text: #79b4f3; --lived-text: #ad98ff; --want-text: #f2b85c;
    --error-bg: #3b1d24; --error-fg: #fecdd3; --error-border: #7f1d2d;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
  @media (prefers-color-scheme: light) {
    :root {
      --bg: #f3f5f8; --panel: #ffffff; --panel-2: #eef2f7; --border: #dbe2ea;
      --text: #111827; --muted: #5b6570; --accent: #1b6ac9; --on-accent: #fff;
      --been: #3e8ede; --lived: #7a5af8; --want: #e19a2b; --unvisited: #d8d3ca;
      --been-text: #216bb6; --lived-text: #6841d6; --want-text: #946008;
      --error-bg: #fdecef; --error-fg: #9f1239; --error-border: #f9a8b8;
      --shadow: 0 10px 30px rgba(15, 23, 42, .10);
    }
  }
  * { box-sizing: border-box; margin: 0; }
  [hidden] { display: none !important; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    background: var(--bg); color: var(--text); min-height: 100vh;
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
    padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
             max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  main { width: 100%; max-width: 1180px; margin: 0 auto; display: grid; gap: 20px; }
  main > * { min-width: 0; }
  button { font: inherit; color: inherit; }
  a { color: var(--accent); }
  :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
  .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }

  /* Header */
  header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
  .brand { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
  header h1 { font-size: clamp(22px, 2.6vw, 28px); font-weight: 700; letter-spacing: -.01em; }
  header h1 span { display: inline-flex; align-items: center; gap: 10px; }
  header h1 svg { width: 28px; height: 28px; flex: none; }
  header p { color: var(--muted); font-size: 14px; }
  .privacy { display: inline-flex; align-items: center; gap: 6px; }
  .privacy svg { width: 16px; height: 16px; flex: none; }
  .intro { max-width: 640px; padding-top: 4px; }
  .intro h2 { font-size: clamp(24px, 3vw, 36px); line-height: 1.2; letter-spacing: -.025em; font-weight: 650; margin-bottom: 8px; }
  .intro p { color: var(--muted); }
  body.has-map .intro, body.has-map #sample { display: none; }

  /* Drop zone */
  #drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; text-align: center; cursor: pointer;
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 34px 28px; background: var(--panel); color: var(--muted);
    transition: border-color .15s, background-color .15s, padding .2s;
  }
  #drop strong { color: var(--text); font-weight: 600; font-size: 17px; }
  #drop small { font-size: 13px; }
  #drop.hover, #drop:hover { border-color: var(--accent); }
  #drop.hover { background: var(--panel-2); }
  body.has-map #drop { padding: 14px 18px; flex-direction: row; gap: 12px; }
  body.has-map #drop small { display: none; }
  body.has-map #drop strong { font-size: 15px; }
  #file:focus-visible + #drop { outline: 3px solid var(--accent); outline-offset: 4px; }
  .drop-icon { width: 36px; height: 36px; color: var(--accent); }
  body.has-map .drop-icon { width: 22px; height: 22px; }
  .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
  .btn {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    border: 1px solid var(--border); background: var(--panel); border-radius: 999px;
    padding: 9px 16px; font-size: 14px; font-weight: 500; min-height: 44px;
    transition: background-color .15s, border-color .15s, transform .08s;
  }
  .btn:hover { border-color: var(--accent); }
  .btn:active { transform: scale(.98); }
  .btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
  .btn.primary:hover { filter: brightness(1.08); }
  .btn[disabled] { opacity: .55; cursor: default; }
  .btn svg { width: 16px; height: 16px; }

  /* Status */
  #status {
    display: none; align-items: flex-start; gap: 10px; border-radius: 12px;
    padding: 12px 14px; font-size: 14px; background: var(--panel); border: 1px solid var(--border);
  }
  #status.visible { display: flex; }
  #status.error { background: var(--error-bg); color: var(--error-fg); border-color: var(--error-border); }
  #status .spinner {
    width: 16px; height: 16px; border-radius: 50%; flex: none; margin-top: 3px;
    border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* Summary line */
  #summary { display: none; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 14px; }
  #summary.visible { display: flex; }
  #summary b { color: var(--text); font-weight: 600; }
  #summary span { overflow-wrap: anywhere; min-width: 0; }

  /* Stats */
  #stats {
    display: none; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  }
  #stats.visible { display: grid; }
  .stat {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; display: grid; gap: 4px; position: relative; overflow: hidden;
  }
  .stat::before {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--stat-color, var(--border));
  }
  .stat .n { font-size: clamp(26px, 3vw, 34px); font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
  .stat .l { font-size: 13px; color: var(--muted); }
  .stat.countries { --stat-color: var(--accent); }
  .stat.been { --stat-color: var(--been); } .stat.been .n { color: var(--been-text); }
  .stat.lived { --stat-color: var(--lived); } .stat.lived .n { color: var(--lived-text); }
  .stat.want { --stat-color: var(--want); } .stat.want .n { color: var(--want-text); }
  .progress { height: 6px; border-radius: 999px; background: var(--panel-2); overflow: hidden; margin-top: 8px; }
  .progress > div { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--been), var(--lived)); transition: width .6s ease; }

  /* Segmented basis switch + legend */
  .toolbar { display: none; flex-wrap: wrap; gap: 12px 18px; align-items: center; justify-content: space-between; }
  .toolbar.visible { display: flex; }
  .segmented { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
  .segmented button {
    border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; cursor: pointer;
    font-size: 13px; color: var(--muted); min-height: 44px; min-width: 0; line-height: 1.3;
  }
  .segmented button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
  .legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); }
  .legend span { display: inline-flex; align-items: center; gap: 6px; }
  .legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: var(--c); }

  /* Map */
  .map-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
  .map-scroller { position: relative; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  #map { display: block; width: 100%; height: auto; background: var(--bg); touch-action: pan-x pan-y; }
  #map.interactive { cursor: crosshair; }
  #tooltip {
    position: absolute; pointer-events: none; z-index: 2; display: none;
    background: var(--panel); color: var(--text); border: 1px solid var(--border);
    border-radius: 10px; padding: 8px 12px; font-size: 13px; line-height: 1.35;
    box-shadow: var(--shadow); width: min(240px, calc(100% - 16px)); overflow-wrap: anywhere;
  }
  #tooltip.visible { display: block; }
  #tooltip .name { font-weight: 600; }
  #tooltip .st { display: flex; align-items: center; gap: 6px; color: var(--muted); }
  #tooltip .st i { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--unvisited)); display: inline-block; }
  .map-foot { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
  .pan-hint { display: none; }
  @media (max-width: 640px) {
    #map { min-width: 760px; }
    .pan-hint { display: inline; }
  }

  /* Places list */
  #places { display: none; gap: 14px; }
  #places.visible { display: grid; }
  #places h2 { font-size: 18px; font-weight: 600; }
  .places-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
  #results-count { color: var(--muted); font-size: 13px; }
  .search-field { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; }
  .search-field:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }
  .search-field svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
  #place-search { width: 100%; min-width: 0; min-height: 48px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: max(16px, 1em); }
  #place-search::placeholder { color: var(--muted); opacity: 1; }
  #reset-filters { width: fit-content; }
  .chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .chip {
    border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 6px 14px;
    font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  }
  .chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); display: inline-block; }
  .chip b { font-weight: 600; color: var(--muted); }
  .chip[aria-pressed="true"] { border-color: var(--accent); background: var(--panel-2); }
  .chip[aria-pressed="true"] b { color: var(--text); }
  .continents { columns: 320px; column-gap: 14px; }
  .continent { break-inside: avoid; margin-bottom: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
  .continent h3 { font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
  .continent h3 span { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
  .continent ul { list-style: none; padding: 0; display: grid; gap: 2px; }
  .continent li { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 14px; border-top: 1px solid var(--border); }
  .continent li:first-child { border-top: 0; }
  .continent li i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
  .continent li .name { flex: 1; min-width: 0; }
  .continent li .sub { display: block; color: var(--muted); font-size: 12px; }
  .continent li .tag { color: var(--muted); font-size: 12px; text-align: right; flex: 0 0 auto; max-width: 30%; }
  .empty { column-span: all; color: var(--muted); font-size: 14px; padding: 8px 0; overflow-wrap: anywhere; }

  footer { color: var(--muted); font-size: 13px; text-align: center; line-height: 1.6; }

  @media (max-width: 640px) {
    body { font-size: 15px; }
    #drop { padding: 26px 18px; }
    .stat { padding: 12px 14px; }
    #stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .continents { columns: 1; }
    .toolbar { justify-content: flex-start; }
    .segmented { display: flex; width: 100%; }
    .segmented button { flex: 1; font-size: 13px; padding: 6px 8px; }
    .segmented { border-radius: 16px; }
    .segmented button { border-radius: 12px; }
    .privacy { font-size: 13px; }
  }
  @media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation-duration: .01ms !important; }
  }

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('fonts/manrope-latin-wght-normal.woff2') format('woff2');
}
:root {
  color-scheme: light;
  --bg: #F4F7FC; --panel: #FFFFFF; --panel-2: #EEF3FA; --border: #DDE4EF;
  --text: #172238; --muted: #5B6577; --accent: #2D5BD1; --on-accent: #FFFFFF;
  --been: #3E8EDE; --lived: #7A5AF8; --want: #E19A2B; --unvisited: #D8D3CA;
  --been-text: #216BB6; --lived-text: #6841D6; --want-text: #946008;
  --error-bg: #FDECEF; --error-fg: #9F1239; --error-border: #F9A8B8;
  --radius: 18px; --shadow: 0 12px 36px rgba(23, 34, 56, .06);
}
body { font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
main { gap: 24px; }
.viewer-masthead { min-height: 78px; padding: 8px 0 24px; gap: 16px 24px; }
.viewer-masthead .brand { gap: 12px; }
.viewer-masthead h1 { font-size: 24px; letter-spacing: -.04em; }
.viewer-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.viewer-brand img { width: 36px; height: 36px; border-radius: 10px; }
.viewer-masthead nav { display: flex; flex-wrap: wrap; gap: 12px 24px; font-size: 14px; }
.viewer-masthead nav a { color: var(--muted); text-decoration: none; }
.viewer-masthead nav a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.intro { padding-top: 18px; max-width: 760px; }
.intro h2 { font-size: clamp(30px, 4vw, 48px); letter-spacing: -.045em; font-weight: 700; }
.intro > p { max-width: 690px; }
.intro .privacy { margin-top: 14px; color: var(--text); font-size: 14px; }
#drop { min-height: 150px; border-color: #C1CEE5; }
body.has-map #drop { min-height: 64px; }
.actions { justify-content: flex-start; }
.btn { font-weight: 600; }
.status-been { --c: var(--been); }
.status-lived { --c: var(--lived); }
.status-want { --c: var(--want); }
.status-unvisited { --c: var(--unvisited); }
.viewer-footer { padding: 18px 0 6px; text-align: left; border-top: 1px solid var(--border); }
.viewer-footer p + p { margin-top: 6px; }
.viewer-footer a { text-underline-offset: 3px; }
.skip-link { position: absolute; top: -80px; left: 16px; z-index: 10; padding: 12px 18px; background: var(--panel); color: var(--accent); border-radius: 10px; }
.skip-link:focus { top: 12px; }
.noscript-notice { padding: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
@media (max-width: 640px) {
  .viewer-masthead { align-items: flex-start; }
  .viewer-masthead nav { width: 100%; font-size: 13px; }
  .intro { padding-top: 4px; }
  main { gap: 20px; }
  .intro h2 { font-size: 32px; }
}
