:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #132235;
  background: #f2f5f7;
  --bg: #f2f5f7;
  --surface: rgba(255,255,255,0.88);
  --surface-solid: #ffffff;
  --text: #132235;
  --muted: #66778b;
  --line: #dce3e8;
  --brand: #ff6b4a;
  --brand-strong: #e95537;
  --brand-soft: #ffe8e1;
  --country: #dce5e7;
  --country-hover: #cbd9dc;
  --visited: #ff6b4a;
  --visited-hover: #e95537;
  --map-stroke: #ffffff;
  --shadow: 0 24px 70px rgba(28, 47, 63, 0.12);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08131f;
  --surface: rgba(14, 29, 44, 0.90);
  --surface-solid: #0e1d2c;
  --text: #edf5f8;
  --muted: #93a6b8;
  --line: #22364a;
  --brand: #ff7a5d;
  --brand-strong: #ff947d;
  --brand-soft: #3a241f;
  --country: #20364a;
  --country-hover: #2b465f;
  --visited: #ff7a5d;
  --visited-hover: #ff9b86;
  --map-stroke: #0b1723;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #08131f;
    --surface: rgba(14, 29, 44, 0.90);
    --surface-solid: #0e1d2c;
    --text: #edf5f8;
    --muted: #93a6b8;
    --line: #22364a;
    --brand: #ff7a5d;
    --brand-strong: #ff947d;
    --brand-soft: #3a241f;
    --country: #20364a;
    --country-hover: #2b465f;
    --visited: #ff7a5d;
    --visited-hover: #ff9b86;
    --map-stroke: #0b1723;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; background:
  radial-gradient(circle at 12% -10%, color-mix(in srgb, var(--brand) 13%, transparent), transparent 36rem),
  var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }

.app-shell { width: min(1500px, 100%); margin: 0 auto; padding: 0 28px; }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; font-weight: 850; font-size: 1.3rem; letter-spacing: -0.03em; }
.brand-mark { width: 34px; height: 34px; border-radius: 50% 50% 50% 12px; transform: rotate(-45deg); background: var(--brand); display: grid; place-items: center; box-shadow: 0 7px 16px color-mix(in srgb, var(--brand) 30%, transparent); }
.brand-mark span { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-solid); }
.top-controls { display: flex; gap: 10px; align-items: center; }
.segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); backdrop-filter: blur(12px); }
.segmented button { min-width: 42px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font-size: .8rem; font-weight: 800; }
.segmented button.active { color: var(--text); background: var(--surface-solid); box-shadow: 0 2px 8px rgba(10,30,45,.08); }
.theme-switch button { min-width: 34px; font-size: 1rem; }

main { padding: 54px 0 34px; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 26px; }
.hero h1 { margin: 4px 0 10px; font-size: clamp(2.2rem, 4.2vw, 4.7rem); line-height: .98; letter-spacing: -0.055em; max-width: 800px; }
.hero p { margin: 0; max-width: 720px; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }
.eyebrow { font-size: .72rem; font-weight: 900; letter-spacing: .22em; color: var(--brand); }
.primary, .secondary { min-height: 46px; border-radius: 14px; padding: 0 18px; font-weight: 850; cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.primary { background: var(--brand); color: #fff; box-shadow: 0 12px 28px color-mix(in srgb, var(--brand) 27%, transparent); }
.primary:hover { background: var(--brand-strong); }
.secondary { background: var(--surface-solid); border-color: var(--line); }
.wide { width: 100%; }
.notice { padding: 12px 15px; margin: 0 0 16px; border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); border-radius: 14px; background: var(--brand-soft); }

.workspace { display: grid; grid-template-columns: 335px minmax(0, 1fr); gap: 18px; align-items: stretch; }
.sidebar, .map-card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.sidebar { padding: 18px; display: flex; flex-direction: column; gap: 18px; min-height: 630px; }
.stats-card { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats-card > div { padding: 17px; border-radius: 17px; background: color-mix(in srgb, var(--surface-solid) 72%, transparent); border: 1px solid var(--line); }
.stats-card strong { display: block; font-size: 1.65rem; letter-spacing: -0.04em; }
.stats-card span { display: block; color: var(--muted); font-size: .74rem; margin-top: 4px; line-height: 1.2; }
.search-wrap { position: relative; }
.country-search { width: 100%; height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-solid); color: var(--text); padding: 0 14px; }
.search-results { position: absolute; z-index: 20; top: 54px; left: 0; right: 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-solid); box-shadow: 0 18px 45px rgba(0,0,0,.16); }
.search-results button { width: 100%; border: 0; background: transparent; display: flex; justify-content: space-between; padding: 11px 13px; cursor: pointer; text-align: left; }
.search-results button:hover { background: var(--brand-soft); }
.selected-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.selected-head h2 { font-size: .9rem; margin: 0; }
.text-button { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: .76rem; padding: 4px; }
.text-button.danger:hover { color: var(--brand); }
.country-list { display: flex; flex-direction: column; gap: 7px; overflow-y: auto; max-height: 420px; padding-right: 2px; }
.country-chip { display: flex; justify-content: space-between; gap: 12px; align-items: center; width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 11px; background: color-mix(in srgb, var(--surface-solid) 70%, transparent); padding: 8px 11px; text-align: left; cursor: pointer; }
.country-chip:disabled { cursor: default; opacity: 1; }
.country-chip:not(:disabled):hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.muted { color: var(--muted); line-height: 1.5; font-size: .86rem; }

.map-card { position: relative; min-height: 630px; overflow: hidden; display: grid; place-items: center; background:
  radial-gradient(circle at 50% 48%, color-mix(in srgb, var(--brand) 7%, transparent), transparent 32rem),
  var(--surface); }
.map-card svg { width: 100%; height: auto; max-height: 700px; }
.map-hint { position: absolute; left: 16px; bottom: 14px; font-size: .72rem; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 9px; backdrop-filter: blur(10px); }
.map-loading { position: absolute; z-index: 5; inset: 0; display: grid; place-items: center; background: var(--surface); color: var(--muted); }

footer { display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: .72rem; padding: 22px 2px 34px; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; background: rgba(3,11,18,.66); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(8px); }
.modal { position: relative; width: min(470px, 100%); background: var(--surface-solid); color: var(--text); border: 1px solid var(--line); border-radius: 24px; padding: 30px; box-shadow: 0 30px 100px rgba(0,0,0,.38); }
.modal-close { position: absolute; top: 13px; right: 13px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg); cursor: pointer; font-size: 1.3rem; }
.modal-mark { width: 44px; height: 44px; border-radius: 14px; background: var(--brand); color: white; display: grid; place-items: center; font-weight: 900; margin-bottom: 18px; }
.modal h2 { margin: 0 0 8px; font-size: 1.65rem; letter-spacing: -.035em; }
.modal p { margin: 0 0 20px; color: var(--muted); line-height: 1.55; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; background: var(--bg); border-radius: 12px; margin-bottom: 18px; }
.tabs button { height: 38px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-weight: 800; color: var(--muted); }
.tabs button.active { background: var(--surface-solid); color: var(--text); box-shadow: 0 2px 9px rgba(0,0,0,.08); }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form label { display: flex; flex-direction: column; gap: 7px; font-size: .82rem; font-weight: 750; }
.auth-form input { height: 47px; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 12px; padding: 0 12px; }
.auth-form small { color: var(--muted); font-weight: 500; }
.error-box { padding: 11px 13px; border-radius: 11px; background: color-mix(in srgb, #d93131 12%, transparent); border: 1px solid color-mix(in srgb, #d93131 35%, var(--line)); color: color-mix(in srgb, #d93131 75%, var(--text)); font-size: .82rem; line-height: 1.4; }
.page-error { margin-bottom: 16px; }

@media (max-width: 900px) {
  .app-shell { padding: 0 16px; }
  .topbar { height: 70px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .share-button, .hero .secondary { width: 100%; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  .country-list { max-height: 230px; }
  .map-card { min-height: 440px; order: -1; }
}

@media (max-width: 560px) {
  main { padding-top: 36px; }
  .brand { font-size: 1.1rem; }
  .brand-mark { width: 30px; height: 30px; }
  .top-controls { gap: 6px; }
  .segmented { padding: 2px; }
  .segmented button { min-width: 34px; height: 31px; }
  .hero h1 { font-size: 2.7rem; }
  .hero p { font-size: .95rem; }
  .map-card { min-height: 350px; border-radius: 18px; }
  .sidebar { border-radius: 18px; }
  footer { flex-direction: column; gap: 6px; }
  .modal { padding: 24px 20px; }
}

.share-ready { padding: 13px 14px; margin: 0 0 16px; border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); border-radius: 14px; background: var(--brand-soft); display: grid; gap: 10px; }
.share-ready > span { font-weight: 800; font-size: .86rem; }
.share-ready > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.share-ready input { min-width: 0; height: 42px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-solid); color: var(--text); padding: 0 11px; font-size: .78rem; }
.share-ready .secondary { min-height: 42px; }
@media (max-width: 560px) { .share-ready > div { grid-template-columns: 1fr; } }

/* Vanilla SVG map (no frontend framework/runtime dependency). */
.world-map { display: block; width: 100%; touch-action: none; user-select: none; cursor: grab; }
.world-map.is-dragging { cursor: grabbing; }
.country-path {
  fill: var(--country);
  stroke: var(--map-stroke);
  stroke-width: .45;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill .12s ease;
}
.country-path:hover { fill: var(--country-hover); }
.country-path.is-visited { fill: var(--visited); }
.country-path.is-visited:hover { fill: var(--visited-hover); }
.country-path:focus-visible { outline: none; stroke: var(--brand); stroke-width: 2; }
.map-controls { position: absolute; top: 14px; right: 14px; display: grid; gap: 6px; z-index: 10; }
.map-controls button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--text); font-weight: 900; cursor: pointer; backdrop-filter: blur(10px); box-shadow: 0 5px 18px rgba(0,0,0,.08); }
.map-controls button:hover { background: var(--surface-solid); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
