/* Inter, self-hosted (SIL Open Font License 1.1, see fonts/Inter-OFL.txt) */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 1000; font-display: swap;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  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: "Inter"; font-style: normal; font-weight: 100 1000; font-display: swap;
  src: url("/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: italic; font-weight: 100 1000; font-display: swap;
  src: url("/fonts/inter-latin-wght-italic.woff2") format("woff2");
  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: "Inter"; font-style: italic; font-weight: 100 1000; font-display: swap;
  src: url("/fonts/inter-latin-ext-wght-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* Etymology Map: styles for the home page (index.html).
   Theme: follows the system setting; the header toggle saves an override
   as data-theme on <html>. View: data-view="map" | "globe" on <html>.
   State: data-state="landing" | "result" on #app. */

:root {
  --bg: #ffffff;
  --card: #ffffff;
  --mapbg: #fbfaf7;
  --land: #ddd8ca;
  --land-border: #c6bfae;
  --border: #e3e1db;
  --hair: #f0eee8;
  --text: #2a2a28;
  --text-dim: #6b6a64;
  --accent: #b3541e;
  --accent-hover: #9a4718;
  --accent-press: #823b12;
  --accent-text: #9a4718;       /* accent text on the soft tint (AA contrast) */
  --accent-soft: #f3e3d3;
  --selected: #fdf6ee;
  --on-accent: #ffffff;
  --theme-icon: #d9a21b;
  --shadow: rgba(0, 0, 0, 0.1);
  --scrim: rgba(30, 25, 15, 0.35);
  --glow: rgba(214, 110, 40, 0.20);
  --error: #b42318;
  /* globe */
  --g-ocean-1: #fffdf8;
  --g-ocean-2: #eadcc4;
  --g-land-1: #ecd6b6;
  --g-land-2: #d8bb90;
  --g-coast: #b98f5c;
  --g-shade: #7a5230;
  --g-shade-opacity: 0.3;
  --g-atmo-opacity: 0.035;
  --g-route: #b3541e;
  --g-pin: #b3541e;
  --g-pin-text: #ffffff;
  --g-glow-display: none;
  color-scheme: light;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110d;
    --card: #1c1811;
    --mapbg: #17130e;
    --land: #2b271e;
    --land-border: #423c30;
    --border: #3a352c;
    --hair: #26221a;
    --text: #f1ece2;
    --text-dim: #a89e8c;
    --accent: #e2934f;
    --accent-hover: #f0a768;
    --accent-press: #c97d3c;
    --accent-text: #e2934f;
    --accent-soft: rgba(226, 147, 79, 0.16);
    --selected: rgba(226, 147, 79, 0.1);
    --on-accent: #14110d;
    --theme-icon: #e2b04a;
    --shadow: rgba(0, 0, 0, 0.45);
    --scrim: rgba(0, 0, 0, 0.6);
    --glow: rgba(255, 122, 60, 0.06);
    --error: #f97066;
    --g-ocean-1: #2b2118;
    --g-ocean-2: #0c0906;
    --g-land-1: #4d3522;
    --g-land-2: #2b1e13;
    --g-coast: #ff9a55;
    --g-shade: #000000;
    --g-shade-opacity: 0.55;
    --g-atmo-opacity: 0.06;
    --g-route: #ffd0a8;
    --g-pin: #ff7a3c;
    --g-pin-text: #14110d;
    --g-glow-display: block;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14110d;
  --card: #1c1811;
  --mapbg: #17130e;
  --land: #2b271e;
  --land-border: #423c30;
  --border: #3a352c;
  --hair: #26221a;
  --text: #f1ece2;
  --text-dim: #a89e8c;
  --accent: #e2934f;
  --accent-hover: #f0a768;
  --accent-press: #c97d3c;
  --accent-text: #e2934f;
  --accent-soft: rgba(226, 147, 79, 0.16);
  --selected: rgba(226, 147, 79, 0.1);
  --on-accent: #14110d;
  --theme-icon: #e2b04a;
  --shadow: rgba(0, 0, 0, 0.45);
  --scrim: rgba(0, 0, 0, 0.6);
  --glow: rgba(255, 122, 60, 0.06);
  --error: #f97066;
  --g-ocean-1: #2b2118;
  --g-ocean-2: #0c0906;
  --g-land-1: #4d3522;
  --g-land-2: #2b1e13;
  --g-coast: #ff9a55;
  --g-shade: #000000;
  --g-shade-opacity: 0.55;
  --g-atmo-opacity: 0.06;
  --g-route: #ffd0a8;
  --g-pin: #ff7a3c;
  --g-pin-text: #14110d;
  --g-glow-display: block;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; }
a { color: inherit; }

.icon { display: inline-block; vertical-align: -0.15em; flex: none; }

#app {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Soft warm glow behind the headline */
#app::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 460px;
  background: radial-gradient(closest-side at 50% 30%, var(--glow), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Shared controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.05s;
}
.btn:focus-visible, .icon-btn:focus-visible, .input-icon:focus-visible, .pill-btn:focus-visible,
.view-toggle button:focus-visible, .tray-item:focus-visible, .stop-row:focus-visible,
.example-chip:focus-visible, .origin-pill:focus-visible, .wordlist-item:focus-visible,
.related-word-item:focus-visible, .gpin:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-outline { background: var(--card); color: var(--accent-text); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-small { height: 34px; padding: 0 16px; font-size: 14px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.icon-btn:active { background: var(--accent-soft); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.copied { color: var(--accent-text); border-color: var(--accent); }

/* ---------- Header ---------- */

.site-header {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 88px;
  padding: 0 60px;
  border-bottom: 1px solid var(--hair);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { display: block; width: 38px; height: 38px; border-radius: 10px; flex: none; }
.brand-name { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.brand-accent { color: var(--accent-text); margin-left: 0.28em; }
.header-actions { display: flex; align-items: center; gap: 24px; }
.header-link { font-size: 15px; font-weight: 500; color: var(--text-dim); text-decoration: none; }
.header-link:hover { color: var(--accent-text); }
#theme-toggle-btn { width: 34px; height: 34px; color: var(--theme-icon); }
#theme-toggle-btn:hover { color: var(--theme-icon); }

/* ---------- Hero and search ---------- */

.hero {
  position: relative;
  z-index: 3;
  padding: 62px 24px 0;
  text-align: center;
}
.hero-title {
  margin: 0;
  font-size: 34px;
  line-height: 1.2;
  font-weight: 600;
  color: var(--accent-text);
}
.result-hero { display: none; }
.eyebrow { font-size: 12px; letter-spacing: 0.1em; font-weight: 600; color: var(--text-dim); text-transform: uppercase; }
.result-word { margin: 4px 0; font-size: 44px; line-height: 1.1; font-weight: 600; color: var(--accent-text); text-transform: capitalize; }
.hero-meaning { margin: 0; font-size: 16px; font-style: italic; color: var(--text-dim); }

.search-row {
  position: relative;
  width: min(732px, 100%);
  margin: 40px auto 0;
  display: flex;
  gap: 12px;
  align-items: center;
}
.input-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
.input-wrap input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.input-wrap input::placeholder { color: var(--text-dim); }
.input-wrap input:hover { border-color: var(--text-dim); }
.input-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-icon {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; cursor: pointer; color: #5b5f8a;
}
:root[data-theme="dark"] .input-icon { color: #9a9fd0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .input-icon { color: #9a9fd0; } }
.input-icon:hover { background: var(--accent-soft); }
.trace-arrow { display: none; width: 48px; height: 48px; padding: 0; flex: none; }
.search-buttons { display: flex; gap: 12px; flex: none; }
.btn .chevron { display: inline-flex; transition: transform 0.15s; }
.btn[aria-expanded="true"] { background: var(--accent-soft); }
.btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }

/* Autocomplete (shared by the word box and the origin box) */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 30;
  margin: 0; padding: 0;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 30px var(--shadow);
  overflow: hidden;
  text-align: left;
}
.autocomplete-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 0 14px; min-height: 44px;
  font-size: 15px; cursor: pointer;
  text-transform: capitalize;
}
.autocomplete-item + .autocomplete-item { border-top: 1px solid var(--hair); }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--accent-soft); color: var(--accent-text); }
.autocomplete-item .ac-origin { font-size: 13px; color: var(--text-dim); text-transform: none; }
.autocomplete-item mark { background: none; color: var(--accent-text); font-weight: 700; }

.message {
  margin: 16px auto 0;
  max-width: 560px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 10px 30px var(--shadow);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
  text-align: center;
}
.message .msg-icon {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text);
}
.message .msg-title { display: block; margin-bottom: 6px; font-size: 20px; font-weight: 600; color: var(--text); }
.message-suggestions { display: block; margin-top: 12px; }
.message-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.suggestion-link {
  display: inline-flex; align-items: center; height: 44px; padding: 0 16px; margin: 0 4px;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--card);
  color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer;
}
.suggestion-link:hover { background: var(--accent-soft); }
.hint { display: none; }

/* ---------- Word list (popover on desktop, half-height sheet on phones) ---------- */

.wordlist-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: min(640px, calc(100vw - 32px));
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 40px var(--shadow);
  text-align: left;
}
.sheet-handle, .sheet-title { display: none; }
.wordlist-filter {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--mapbg);
  border-radius: 12px 12px 0 0;
}
.wordlist-filter label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.wordlist-filter select {
  height: 32px; max-width: 220px; min-width: 0; padding: 0 8px;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.wordlist-filter select:focus { outline: none; border-color: var(--accent); }
.origin-search-wrap { position: relative; flex: 1 1 130px; min-width: 100px; }
.origin-search-wrap input {
  width: 100%; height: 32px; padding: 0 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font: inherit; font-size: 13px;
}
.origin-search-wrap input:focus { outline: none; border-color: var(--accent); }
.origin-search-wrap .autocomplete-list { max-height: 200px; overflow-y: auto; }
.origin-search-wrap .autocomplete-item { min-height: 36px; font-size: 13px; text-transform: none; }
.wordlist-count { margin-left: auto; font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }
.wordlist-grid {
  max-height: 264px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 6px;
  padding: 12px;
}
.wordlist-grid.empty { display: block; padding: 40px 12px; text-align: center; color: var(--text-dim); font-size: 14px; }
.wordlist-item {
  padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; text-transform: capitalize; text-align: left;
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wordlist-item:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Stage: layout per view and state ---------- */

.stage {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1108px;
  margin: 48px auto 0;
  padding: 0 16px 48px;
  flex: 1 0 auto;
}

/* Map view ---------------------------------------------------------- */
html[data-view="map"] #globe-stage { display: none; }
html[data-view="globe"] #map-card { display: none; }

.map-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.card-head-landing { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.empty-chips-label { color: var(--text-dim); margin-right: 6px; white-space: nowrap; }
.empty-chips-bar { display: inline-flex; gap: 8px; }
.example-chip {
  padding: 5px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; text-transform: lowercase;
}
.example-chip:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.card-head-result { display: flex; align-items: baseline; gap: 14px; flex: 1 1 auto; min-width: 0; }
.card-word { font-size: 22px; font-weight: 600; color: var(--accent-text); text-transform: capitalize; }
.card-meaning { font-size: 14px; font-style: italic; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-tools { display: flex; align-items: center; gap: 12px; margin-left: auto; flex: none; }
.result-only-tools { display: none; align-items: center; gap: 8px; }
#app[data-state="result"] .result-only-tools { display: inline-flex; }
#app[data-state="result"] .card-head-landing { display: none; }
#app[data-state="landing"] .card-head-result { display: none; }
.zoom-controls { display: inline-flex; gap: 8px; }
.toolbar-divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

.view-toggle {
  display: inline-flex; gap: 2px; padding: 2px; height: 36px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card);
}
.view-toggle button {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--text-dim); font-size: 13px; cursor: pointer;
}
.view-toggle button:hover { color: var(--accent-text); border-color: var(--accent); }
.view-toggle button[aria-checked="true"] {
  background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); font-weight: 600;
}

.map-stage { position: relative; height: 445px; background: var(--mapbg); }
#map { display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
.map-stage.dragging #map { cursor: grabbing; }
.land-path { fill: var(--land); stroke: var(--land-border); stroke-width: 0.6; }
.route-line { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 5; fill: none; vector-effect: non-scaling-stroke; }
.route-arrow { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.pin-group { cursor: pointer; }
.pin-dot { fill: var(--accent); stroke: var(--card); stroke-width: 1.5; }
.pin-halo { fill: var(--accent); fill-opacity: 0.26; display: none; }
.pin-num { fill: var(--on-accent); font-weight: 700; text-anchor: middle; pointer-events: none; }
.pin-label {
  font-weight: 600; fill: var(--text);
  stroke: var(--mapbg); paint-order: stroke; pointer-events: none;
}
.pin-group.active .pin-halo, .pin-group.selected .pin-halo { display: block; }
.map-hint { position: absolute; right: 16px; bottom: 12px; font-size: 12px; color: var(--text-dim); pointer-events: none; }
#app[data-state="result"] .map-hint { display: none; }

/* Stage tray over the bottom of the map */
.tray {
  position: absolute; left: 16px; right: 16px; bottom: 16px;
  display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none;
}
.tray::-webkit-scrollbar { display: none; }
.tray-item {
  flex: 1 0 auto; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); opacity: 0.97; cursor: pointer; white-space: nowrap;
  font-size: 15px; font-weight: 600; text-align: left;
}
.tray-item:hover, .tray-item.active { border-color: var(--accent); }
.tray-item.selected { border-color: var(--accent); background: var(--selected); }
.tray-num, .stop-circle {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%; line-height: 1;
  background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700;
}
.tray-lang { font-size: 12px; font-weight: 400; color: var(--text-dim); }

/* Word of the day card */
.wod-card {
  display: none;
  position: absolute;
  z-index: 4;
  left: 24px; top: 24px;
  width: 290px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 20px var(--shadow);
  text-align: left;
}
#app[data-state="landing"] .wod-card { display: block; }
.wod-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.wod-word { margin: 6px 0 4px; font-size: 30px; font-weight: 600; text-transform: capitalize; }
.wod-meaning { font-size: 13px; font-style: italic; color: var(--text-dim); margin-bottom: 8px; }
.wod-route { font-size: 14px; line-height: 1.5; color: var(--text-dim); }
.wod-route .icon { vertical-align: -0.12em; margin: 0 2px; }
.wod-actions { display: flex; gap: 8px; margin-top: 14px; }
.wod-actions .btn { flex: 1; }

/* ---------- Globe view ---------- */

.globe-stage { position: relative; }
.globe-tools { display: flex; justify-content: flex-end; position: relative; z-index: 6; }
.globe-host { position: relative; }
.globe-svg { display: block; overflow: visible; touch-action: pan-y; cursor: grab; }
.globe-svg.is-dragging { cursor: grabbing; }
.g-ring { fill: none; stroke: var(--accent); stroke-opacity: 0.14; stroke-dasharray: 2 9; stroke-linecap: round; }
.g-grat { fill: none; stroke: var(--accent); stroke-opacity: 0.13; stroke-width: 0.8; }
.g-land { stroke: var(--g-coast); stroke-width: 1.3; stroke-opacity: 0.85; stroke-linejoin: round; }
.g-land-glow { display: var(--g-glow-display); fill: none; stroke: var(--g-coast); stroke-width: 9; opacity: 0.16; stroke-linejoin: round; }
.g-rim { fill: none; stroke: var(--accent); stroke-opacity: 0.38; stroke-width: 1.5; }
.g-arc { fill: none; stroke: var(--g-route); stroke-width: 2.2; stroke-linecap: round; }
.gpin { cursor: pointer; }
.gpin-halo { fill: var(--accent); fill-opacity: 0.3; display: none; }
.gpin.is-active .gpin-halo { display: block; }
.gpin-dot { fill: var(--g-pin); stroke: var(--bg); stroke-width: 1.5; }
.gpin-num { fill: var(--g-pin-text); font-weight: 700; pointer-events: none; font-family: inherit; }
.gpin-label { fill: var(--text); font-weight: 600; stroke: var(--bg); stroke-width: 3px; paint-order: stroke; pointer-events: none; font-family: inherit; }

/* Route reveal: arcs draw, then pins pop in, one after another */
.globe-svg .g-arc { stroke-dasharray: 1; stroke-dashoffset: 1; }
.globe-svg.is-revealed .g-arc { stroke-dashoffset: 0; transition: stroke-dashoffset 0.5s ease-in-out calc(var(--i, 0) * 0.14s + 0.25s); }
.globe-svg .gpin { opacity: 0; }
.globe-svg.is-revealed .gpin { opacity: 1; transition: opacity 0.25s ease calc(var(--i, 0) * 0.14s); }

.globe-caption { display: none; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 14px;
  border: 1px solid var(--border); border-radius: 99px; background: var(--card);
  color: var(--text-dim); font-size: 12px; cursor: pointer;
}
.pill-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); color: var(--text);
}

/* Landing: a large sphere rising from the bottom of the page */
html[data-view="globe"] #app[data-state="landing"] .stage { max-width: none; padding: 0; margin-top: 18px; }
html[data-view="globe"] #app[data-state="landing"] .globe-stage { height: auto; overflow: visible; }
html[data-view="globe"] #app[data-state="landing"] .globe-tools {
  position: absolute; right: 60px; top: 14px;
}
html[data-view="globe"] #app[data-state="landing"] .globe-host {
  --size: var(--gsize, min(1080px, 72vw));
  width: var(--size);
  margin: 0 auto;
  margin-top: calc(var(--size) * 0.0652 * -1 + 10px);
}
html[data-view="globe"] #app[data-state="landing"] .globe-host .globe-svg { width: 100%; height: auto; }
html[data-view="globe"] #app[data-state="landing"] .globe-caption {
  display: flex; justify-content: center; position: absolute; left: 0; right: 0; bottom: 18px; z-index: 5;
}
html[data-view="globe"] #app[data-state="landing"] .wod-card {
  left: max(24px, calc(50% - 630px)); top: 120px;
}
html[data-view="globe"] #app[data-state="landing"] .globe-halo-fix { display: none; }

/* Result: stage list on the left, a whole sphere on the right */
html[data-view="globe"] #app[data-state="result"] .stage {
  display: grid;
  grid-template-columns: minmax(0, 620px) minmax(0, 1fr);
  grid-template-areas: "info globe" "rel rel";
  column-gap: 32px;
  max-width: 1320px;
  padding: 0 40px 48px;
  margin-top: 28px;
}
html[data-view="globe"] #app[data-state="result"] #result-area { grid-area: info; }
html[data-view="globe"] #app[data-state="result"] .globe-stage { grid-area: globe; position: sticky; top: 16px; align-self: start; }
html[data-view="globe"] #app[data-state="result"] #related-words { grid-area: rel; }
html[data-view="globe"] #app[data-state="result"] .globe-host { max-width: 760px; margin: 0 auto; }
html[data-view="globe"] #app[data-state="result"] .globe-host .globe-svg { width: 100%; height: auto; }
html[data-view="globe"] #app[data-state="result"] .globe-caption { display: flex; justify-content: center; margin-top: 4px; }
html[data-view="globe"] #app[data-state="result"] .globe-tools { position: absolute; right: 0; top: 0; }
html[data-view="globe"] #app[data-state="result"] .wod-card { display: none; }

/* ---------- Result area: origin sentence, stage list, story ---------- */

.result-area { margin-top: 20px; }
.origin-sentence { margin: 0 0 18px; font-size: 15px; line-height: 1.55; color: var(--text-dim); }
.origin-question { color: var(--accent-text); }
.panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }

.stop-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  column-gap: 8px;
  align-content: start;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.stop-circle { width: 24px; height: 24px; font-size: 12px; align-self: center; }
.stop-body { display: contents; }
.stop-order { align-self: center; font-size: 11px; letter-spacing: 0.08em; color: var(--text-dim); text-transform: uppercase; }
.stop-main { grid-column: 1 / -1; margin-top: 8px; }
.stop-word { display: block; font-size: 21px; font-weight: 600; }
.stop-lang-era { display: block; font-size: 13px; font-weight: 600; color: var(--accent-text); margin: 2px 0 6px; }
.stop-sub { grid-column: 1 / -1; }
.stop-meaning { display: block; font-size: 13px; font-style: italic; margin-bottom: 4px; }
.stop-note { display: block; font-size: 13px; line-height: 1.45; color: var(--text-dim); }
a.stop-row { color: inherit; text-decoration: none; }
a.route-chip, a.tray-item { text-decoration: none; color: inherit; }
a.route-chip { display: inline-flex; align-items: center; justify-content: center; }
.stage-notice { margin: 10px auto 0; max-width: 560px; font-size: 14px; line-height: 1.5; color: var(--text-dim); text-align: center; pointer-events: auto; }
.stage-notice a { color: var(--accent-text); font-weight: 600; text-decoration: none; }
.stage-notice a:hover { text-decoration: underline; }
.stop-row:hover, .stop-row.active { border-color: var(--accent); }
.stop-row.selected { border-color: var(--accent); background: var(--selected); }


.globe-actions { display: none; gap: 10px; margin-top: 16px; }
html[data-view="globe"] .globe-actions { display: flex; flex-wrap: wrap; }

.full-story {
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}
.full-story summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; min-height: 48px; list-style: none; cursor: pointer;
  font-size: 15px; font-weight: 600; color: var(--accent-text);
}
.full-story summary::-webkit-details-marker { display: none; }
.full-story .summary-chevron { display: inline-flex; transition: transform 0.15s; }
.full-story[open] .summary-chevron { transform: rotate(90deg); }
.full-story[open] { border-color: var(--accent); }
.full-story[open] summary { background: var(--selected); border-bottom: 1px solid var(--border); }
.full-story p { margin: 0; padding: 18px 22px; font-size: 15px; line-height: 1.65; color: var(--text-dim); }
.full-story p em, .full-story p strong { color: var(--text); }

/* ---------- Browse by origin, related words ---------- */

.origin-browse { margin-top: 28px; }
#app[data-state="result"] .origin-browse { display: none; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2, .related-words-title { margin: 0; font-size: 16px; font-weight: 600; }
.browse-count { font-size: 13px; color: var(--text-dim); }
.origin-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.origin-pill {
  display: inline-flex; align-items: center; height: 36px; padding: 0 16px; border: 0; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent-text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.origin-pill:hover { background: var(--accent); color: var(--on-accent); }
.related-words { margin-top: 32px; }
.related-words-title span { color: var(--accent-text); }
.related-words-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.related-word-item {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--card); font-size: 14px; font-weight: 600; text-decoration: none; text-transform: capitalize;
}
.related-word-item:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }

/* ---------- Share modal ---------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 1000; padding: 20px;
  display: flex; align-items: center; justify-content: center;
  background: var(--scrim);
}
.modal-card {
  position: relative; width: 100%; max-width: 620px; max-height: 92vh; overflow: auto;
  padding: 20px 32px 26px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 20px 60px var(--shadow);
}
.modal-close { position: absolute; top: 14px; right: 16px; }
.modal-title { margin: 0 0 14px; padding-right: 56px; font-size: 22px; font-weight: 600; }
.modal-theme-toggle { display: inline-flex; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.modal-theme-btn { min-width: 76px; height: 38px; padding: 0 16px; border: 0; background: var(--card); color: var(--text-dim); font-size: 13px; font-weight: 600; cursor: pointer; }
.modal-theme-btn + .modal-theme-btn { border-left: 1px solid var(--border); }
.modal-theme-btn:hover { color: var(--accent-text); }
.modal-theme-btn.active, .modal-theme-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.modal-preview-wrap { margin-bottom: 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; line-height: 0; background: var(--border); }
#share-preview { display: block; width: 100%; height: auto; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-status { margin: 12px 0 0; font-size: 13px; color: var(--text-dim); }

/* ---------- Footer ---------- */

.site-footer {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 65px; padding: 0 60px;
  border-top: 1px solid var(--hair);
  font-size: 13px; line-height: 20px; color: var(--text-dim);
}
.site-footer { flex-wrap: wrap; }
.footer-about { flex: 1 1 320px; margin: 0; padding: 0; font-size: 13px; line-height: 20px; }
#app[data-state="result"] .footer-about { display: none; }
.footer-links { display: flex; gap: 22px; }
.site-footer a { color: var(--text-dim); text-decoration: none; }
.site-footer a:hover { color: var(--accent-text); }

/* ---------- Motion ---------- */

#app[data-state="result"] #result-area,
#app[data-state="result"] .card-head-result {
  animation: rise-in 0.4s ease both;
}
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .globe-svg .g-arc { stroke-dashoffset: 0; }
  .globe-svg .gpin { opacity: 1; }
}

/* ---------- Tablet ---------- */

@media (max-width: 960px) {
  .site-header, .site-footer { padding: 0 24px; }
  html[data-view="globe"] #app[data-state="result"] .stage {
    display: block; padding: 0 16px 48px; max-width: 760px;
  }
  html[data-view="globe"] #app[data-state="result"] .globe-stage { position: relative; top: 0; margin-bottom: 18px; }
  html[data-view="globe"] #app[data-state="landing"] .globe-tools { right: 24px; }
}

/* ---------- Phones ---------- */

@media (max-width: 640px) {
  .site-header { height: 56px; padding: 0 16px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
  .brand-name { font-size: 18px; }
  .header-link { display: none; }
  #theme-toggle-btn { width: 36px; height: 36px; }
  .hero { padding: 6px 16px 0; }
  .hero-title { font-size: 26px; }
  #app[data-state="result"] .hero-title { display: none; }
  .result-word { font-size: 34px; }
  .search-row { flex-wrap: wrap; margin-top: 18px; gap: 8px; }
  .input-wrap { flex: 1 1 calc(100% - 56px); }
  .input-wrap input { height: 48px; font-size: 16px; }
  .trace-arrow { display: inline-flex; }
  .search-buttons { flex: 1 1 100%; }
  .search-buttons .btn { flex: 1; }
  #app[data-state="result"] .search-row { margin-top: 12px; }

  .stage { margin-top: 20px; padding: 0 16px 32px; }
  .card-head { flex-wrap: wrap; padding: 12px 14px; gap: 8px; }
  .card-head-landing { flex-direction: column; align-items: flex-start; gap: 8px; flex: 1 1 100%; overflow: visible; }
  .empty-chips-bar { display: flex; gap: 8px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .example-chip { height: 44px; padding: 0 14px; }
  .card-head-result { flex-direction: column; gap: 2px; flex: 1 1 100%; }
  .card-meaning { white-space: normal; }
  .card-tools { margin-left: 0; width: 100%; justify-content: space-between; }
  .card-tools .view-toggle { height: 44px; }
  .card-tools .view-toggle button { height: 38px; }
  .icon-btn.small { width: 44px; height: 44px; }
  .result-only-tools { gap: 6px; }
  #share-btn { height: 44px; }
  .zoom-controls { display: none; }
  .toolbar-divider { display: none; }
  .map-stage { height: 200px; }
  #app[data-state="result"] .map-stage { height: 165px; }
  .map-hint { right: 10px; bottom: 6px; }
  .tray { position: static; padding: 12px; border-top: 1px solid var(--border); background: var(--card); }
  .tray-item { flex: none; }
  .wod-card { position: static; width: auto; margin: 16px 0 0; box-shadow: none; }
  #app[data-state="landing"] .wod-card { display: block; }

  .wordlist-panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 52vh;
    display: flex; flex-direction: column;
    border-radius: 18px 18px 0 0; border-bottom: 0;
    z-index: 60;
  }
  .wordlist-panel[hidden] { display: none; }
  .sheet-handle { display: block; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--border); flex: none; }
  .sheet-title { display: flex; align-items: center; justify-content: space-between; padding: 4px 16px 8px; font-size: 20px; font-weight: 600; flex: none; }
  .wordlist-filter { border-radius: 0; background: var(--card); flex: none; }
  .wordlist-filter select { height: 44px; max-width: none; flex: 1 1 100%; font-size: 15px; }
  .wordlist-filter label { display: none; }
  .origin-search-wrap { flex: 1 1 100%; }
  .origin-search-wrap input { height: 44px; font-size: 15px; }
  .wordlist-count { margin-left: 0; }
  .wordlist-grid { flex: 1 1 auto; max-height: none; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 14px 16px; }
  .wordlist-item { height: 44px; padding: 0 8px; display: block; line-height: 42px; }
  #app.sheet-open .hero { z-index: 60; }
  #app.sheet-open .hero::after { content: ""; position: fixed; inset: 0; background: var(--scrim); z-index: 1; pointer-events: none; }
  .wordlist-panel { z-index: 60; }
  .search-row { z-index: 2; }

  /* Globe on phones: a whole sphere, never cropped */
  html[data-view="globe"] #app[data-state="landing"] .stage { padding: 0 16px 32px; margin-top: 12px; }
  html[data-view="globe"] #app[data-state="landing"] .globe-stage { height: auto; overflow: visible; }
  html[data-view="globe"] #app[data-state="landing"] .globe-tools { position: relative; right: auto; top: auto; margin-bottom: 4px; }
  html[data-view="globe"] #app[data-state="landing"] .globe-host,
  html[data-view="globe"] #app[data-state="result"] .globe-host { --size: min(350px, 92vw); width: var(--size); margin: 0 auto; }
  html[data-view="globe"] #app[data-state="landing"] .globe-caption { position: static; margin-top: 4px; }
  html[data-view="globe"] #app[data-state="landing"] .wod-card { position: static; left: auto; top: auto; }
  html[data-view="globe"] #app[data-state="result"] .globe-tools { position: relative; margin-bottom: 4px; }
  .site-footer { padding: 14px 16px; flex-wrap: wrap; }
  .site-footer a { display: inline-flex; align-items: center; min-height: 44px; }
  .footer-links { gap: 14px; }
  .modal-card { padding: 18px 18px 22px; }
}

/* Globe landing: the stage is full-bleed, so re-inset the sections below it */
html[data-view="globe"] #app[data-state="landing"] .origin-browse,
html[data-view="globe"] #app[data-state="landing"] .related-words {
  width: 100%; max-width: 1080px; margin-left: auto; margin-right: auto;
  padding-left: 20px; padding-right: 20px; box-sizing: border-box;
}

/* Desktop globe result ("Result A"): the same rising globe as the landing
   page, with the stages laid out as a strip of cards underneath. */
@media (min-width: 961px) {
  html[data-view="globe"] #app[data-state="result"] .stage {
    display: block; max-width: none; padding: 0 0 48px; margin-top: 18px;
  }
  html[data-view="globe"] #app[data-state="result"] .globe-stage {
    position: relative; top: 0; height: clamp(420px, 48vw, 660px); overflow: hidden;
  }
  html[data-view="globe"] #app[data-state="result"] .globe-tools { position: absolute; right: 60px; top: 14px; }
  html[data-view="globe"] #app[data-state="result"] .globe-host {
    --size: min(1500px, 110vw); width: var(--size); max-width: none;
    margin: calc(var(--size) * 0.0652 * -1 + 10px) auto 0;
  }
  html[data-view="globe"] #app[data-state="result"] .globe-caption {
    position: absolute; left: 0; right: 0; bottom: 18px; margin: 0; z-index: 5;
  }
  html[data-view="globe"] #app[data-state="result"] #result-area,
  html[data-view="globe"] #app[data-state="result"] #related-words {
    width: 100%; max-width: 1180px; margin-left: auto; margin-right: auto; padding: 0 40px; box-sizing: border-box;
  }
  html[data-view="globe"] #app[data-state="result"] #result-area { margin-top: 24px; }
  html[data-view="globe"] #app[data-state="result"] .panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
  html[data-view="globe"] #app[data-state="result"] .stop-row {
    display: grid; grid-template-columns: 24px 1fr; width: auto; padding: 16px 18px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--card);
  }
  html[data-view="globe"] #app[data-state="result"] .stop-row:hover,
  html[data-view="globe"] #app[data-state="result"] .stop-row.selected { border-color: var(--accent); border-radius: 12px; }
  html[data-view="globe"] #app[data-state="result"] .stop-row.selected { background: var(--selected); }
  html[data-view="globe"] #app[data-state="result"] .stop-circle { width: 24px; height: 24px; font-size: 12px; align-self: center; }
  html[data-view="globe"] #app[data-state="result"] .stop-body { display: contents; }
  html[data-view="globe"] #app[data-state="result"] .stop-order { display: block; }
  html[data-view="globe"] #app[data-state="result"] .stop-main { display: block; margin-top: 8px; grid-column: 1 / -1; }
  html[data-view="globe"] #app[data-state="result"] .stop-lang-era { margin: 2px 0 6px; }
  html[data-view="globe"] #app[data-state="result"] .stop-meaning,
  html[data-view="globe"] #app[data-state="result"] .stop-note { display: block; }
  html[data-view="globe"] #app[data-state="result"] .stop-meaning::after { content: none; }
}

/* ---------- Route chips, story extras ---------- */
.route-chips { display: none; }
.story-grid { display: block; }

/* ---------- Map -> globe entrance ---------- */
@keyframes globe-in {
  0% { opacity: 0; transform: translateY(46px) scale(0.93); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}
@keyframes map-in {
  0% { opacity: 0; transform: scale(0.97); filter: blur(3px); }
  100% { opacity: 1; transform: none; filter: none; }
}
html.view-to-globe #globe-stage .globe-host { animation: globe-in 1.1s cubic-bezier(.2,.8,.2,1) both; }
html.view-to-map #map { animation: map-in 0.6s ease both; }

/* ---------- Desktop globe result ("Result A, story open") ---------- */
@media (min-width: 961px) {
  html[data-view="globe"] #app[data-state="result"] .hero-title { display: none; }
  html[data-view="globe"] #app[data-state="result"] .result-hero { display: block; text-align: center; }
  html[data-view="globe"] #app[data-state="result"] .route-chips:not([hidden]) {
    display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px; margin-top: 22px;
  }
  .route-chip {
    height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--card); color: var(--text); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  }
  .route-chip:hover, .route-chip.selected { border-color: var(--accent); }
  .route-chip.selected { background: var(--selected); }
  .chip-arrow { color: var(--accent-text); }

  html[data-view="globe"] #app[data-state="result"] .globe-stage {
    height: auto; overflow: visible;
  }
  html[data-view="globe"] #app[data-state="result"] .stage { --gsize: min(1080px, 72vw); margin-top: 44px; overflow-x: clip; }
  html[data-view="globe"] #app[data-state="result"] .globe-host { --size: var(--gsize); }
  html[data-view="globe"] #app[data-state="result"] .globe-caption { position: absolute; top: 14px; left: 60px; bottom: auto; right: auto; justify-content: flex-start; margin: 0; }
  /* The stage strip: one joined card laid over the lower part of the globe */
  html[data-view="globe"] #app[data-state="result"] #result-area { margin-top: calc(var(--gsize, 1200px) * -0.635 - 10px); position: relative; z-index: 6; }
  html[data-view="globe"] #app[data-state="result"] .origin-sentence { display: none; }
  html[data-view="globe"] #app[data-state="result"] .panel {
    display: flex; gap: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
    background: color-mix(in srgb, var(--card) 94%, transparent); box-shadow: 0 10px 30px rgba(0,0,0,.22);
  }
  html[data-view="globe"] #app[data-state="result"] .stop-row {
    flex: 1 1 0; min-width: 0; border: 0; border-radius: 0; background: transparent;
  }
  html[data-view="globe"] #app[data-state="result"] .stop-row + .stop-row { border-left: 1px solid var(--border); }
  html[data-view="globe"] #app[data-state="result"] .stop-row:hover,
  html[data-view="globe"] #app[data-state="result"] .stop-row.selected {
    border: 0; border-radius: 0; background: var(--selected); border-left: 1px solid var(--border);
  }
  html[data-view="globe"] #app[data-state="result"] .globe-actions { margin-top: 14px; }

  #app[data-state="result"] .story-grid {
    display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 36px; padding: 6px 24px 24px;
  }
  #app[data-state="result"] .full-story p { padding: 12px 0; }
  #app[data-state="result"] .story-stages { display: block; list-style: none; margin: 0; padding: 0; }
  #app[data-state="result"] .story-stages li { display: block; padding: 12px 0; border-top: 1px solid var(--border); }
  #app[data-state="result"] .ss-label {
    display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim);
  }
  #app[data-state="result"] .ss-word { display: block; font-size: 19px; font-weight: 600; margin: 2px 0; }
  #app[data-state="result"] .ss-text { font-size: 14px; color: var(--text-dim); }
  #app[data-state="result"] .story-glance { display: block; padding-top: 12px; }
  .story-glance h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-text); }
  .glance-row { padding: 10px 0; border-top: 1px solid var(--border); }
  .glance-k { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
  .glance-v { display: block; font-size: 15px; font-weight: 600; margin-top: 2px; }
  .glance-arrow { color: var(--accent-text); }
}

/* Whole sphere visible on the homepage, too; content floats over its lower half */
@media (min-width: 961px) {
  html[data-view="globe"] #app[data-state="landing"] .stage { --gsize: min(1080px, 72vw); margin-top: 44px; overflow-x: clip; }
  html[data-view="globe"] #app[data-state="landing"] .origin-browse {
    position: relative; z-index: 6; margin-top: calc(var(--gsize) * -0.385 - 10px);
  }
  html[data-view="globe"] #app[data-state="landing"] .globe-tools,
  html[data-view="globe"] #app[data-state="landing"] .globe-caption { top: 14px; }
  html[data-view="globe"] #app[data-state="landing"] .globe-caption { position: absolute; left: 60px; right: auto; bottom: auto; justify-content: flex-start; }
  html[data-view="globe"] #app[data-state="landing"] .globe-tools { right: 60px; }
  /* keep the footer below the sphere's lower edge */
  html[data-view="globe"] #app[data-state="result"] .related-words { position: relative; z-index: 6; }
  html[data-view="globe"] #app[data-state="landing"] .related-words { position: relative; z-index: 6; }
}
@media (min-width: 961px) {
    }

/* ---------- Story panel in every view ---------- */
#app[data-state="result"] .story-stages { display: block; list-style: none; margin: 0; padding: 0; }
#app[data-state="result"] .story-glance { display: block; }
#app[data-state="result"] .story-grid { display: block; padding: 4px 18px 20px; }
#app[data-state="result"] .full-story p { padding: 12px 0; }
@media (min-width: 961px) {
  #app[data-state="result"] .story-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 36px; padding: 6px 24px 24px; }
}


/* ---------- Drag hint, pin selection fixes, clickable toggle ---------- */
.globe-hint {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; margin-right: 8px;
  border: 1px solid var(--border); border-radius: 99px; background: var(--card);
  color: var(--text-dim); font-size: 12px; pointer-events: none; transition: opacity 0.4s;
}
.globe-hint.gone { opacity: 0; }
.globe-hint[hidden] { display: none; }
.globe-caption { gap: 0; align-items: center; }
.globe-svg, .globe-svg * { user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.globe-svg { cursor: grab; touch-action: pan-y; }
.globe-svg.is-dragging, .globe-svg.is-dragging * { cursor: grabbing; }
.gpin:focus { outline: none; }
.gpin:focus-visible .gpin-dot { stroke: var(--accent); stroke-width: 3; }
/* the hero's empty box must not swallow clicks aimed at the globe controls */
.hero, .result-hero, .route-chips { pointer-events: none; }
.search-row, .route-chip, .message, .hint { pointer-events: auto; }
.globe-tools { z-index: 8; }

/* ---------- Globe top bar: actions on the left, hint + rotation + view toggle on the right ---------- */
html[data-view="globe"] .globe-stage .globe-tools { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
html[data-view="globe"] #app .globe-stage .globe-tools .globe-caption {
  display: flex; position: static; margin: 0; left: auto; right: auto; top: auto; bottom: auto; justify-content: flex-end; gap: 0;
}
#app[data-state="landing"] .globe-actions { display: none !important; }
html[data-view="globe"] #app[data-state="result"] .globe-actions { display: flex; margin: 0 0 10px; }
@media (min-width: 961px) {
  html[data-view="globe"] #app[data-state="result"] .globe-actions {
    position: absolute; left: 60px; top: 10px; z-index: 8; margin: 0;
  }
  html[data-view="globe"] #app[data-state="result"] .globe-actions .btn { height: 36px; }
}
.globe-hint, .pill-btn { white-space: nowrap; }
html[data-view="globe"] .globe-stage .globe-tools { flex-wrap: wrap; }
@media (min-width: 961px) {
  html[data-view="globe"] #app[data-state="result"] .stage { margin-top: 76px; }
}
@media (max-width: 640px) {
  html[data-view="globe"] .globe-stage .globe-tools, html[data-view="globe"] #app .globe-stage .globe-tools .globe-caption { justify-content: center; }
}

/* Map-card top bar: share + link at the far left */
.head-actions { display: none; align-items: center; gap: 8px; flex: none; }
#app[data-state="result"] .head-actions { display: flex; }

/* Clear the globe controls from the search row at every width */
@media (min-width: 961px) {
  html[data-view="globe"] #app[data-state="landing"] .stage { margin-top: 76px; }
}

/* Browse by origin: centered */
.origin-browse { text-align: center; }
.origin-browse .section-head { justify-content: center; gap: 14px; }
.origin-pills { justify-content: center; }

/* ---------- Matching control heights ---------- */
#share-btn, #share-btn-globe, .head-actions .icon-btn.small, .globe-actions .icon-btn.small { height: 36px; }
.head-actions .icon-btn.small, .globe-actions .icon-btn.small { width: 36px; }
#share-btn, #share-btn-globe { padding: 0 14px; font-size: 13px; }

/* ---------- Phones and tablets: compact top bars ---------- */
@media (max-width: 960px) {
  /* globe controls share one row; the rotation pill drops under on results */
  html[data-view="globe"] .globe-stage { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
  html[data-view="globe"] .globe-stage .globe-tools { display: contents; }
  html[data-view="globe"] .globe-stage .globe-tools .globe-caption { order: 1; flex: 0 0 auto; margin: 0; }
  html[data-view="globe"] .globe-stage .globe-tools .view-toggle { order: 2; margin-left: auto; }
  html[data-view="globe"] .globe-stage .globe-host { order: 4; flex: 0 0 100%; }
  html[data-view="globe"] #app[data-state="result"] .globe-stage .globe-actions { order: 0; margin: 0; position: static; }
  html[data-view="globe"] #app[data-state="result"] .globe-stage .globe-tools .globe-caption { order: 3; flex: 0 0 100%; justify-content: center; }
  html[data-view="globe"] .globe-stage .globe-hint { display: none; }
  html[data-view="globe"] .globe-stage .globe-tools { position: static; }
}
@media (max-width: 640px) {
  .card-head { flex-wrap: nowrap; align-items: center; gap: 8px; }
  .card-head-landing { flex: 1 1 0; flex-direction: row; align-items: center; overflow: hidden; gap: 6px; }
  .empty-chips-label { display: none; }
  .empty-chips-bar { overflow: hidden; }
  .example-chip { height: 36px; padding: 0 12px; font-size: 13px; }
  .card-tools { width: auto; margin-left: auto; flex: none; }
  .card-tools .view-toggle { height: 40px; }
  .card-tools .view-toggle button { height: 34px; padding: 0 10px; }
  #share-btn, #share-btn-globe { height: 40px; }
  .head-actions .icon-btn.small, .globe-actions .icon-btn.small { width: 40px; height: 40px; }
  .view-toggle { height: 40px; }
  .view-toggle button { height: 34px; }
  .pill-btn { height: 40px; }
  #app[data-state="result"] .card-head { padding: 10px 12px; }
}

/* ---------- Story panel: stage breakdown + At a glance (all widths) ---------- */
.story-stages { counter-reset: stg; }
#app[data-state="result"] .story-stages li {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 14px; row-gap: 1px;
  padding: 14px 0; border-top: 1px solid var(--border);
}
#app[data-state="result"] .story-stages li::before {
  counter-increment: stg; content: counter(stg);
  grid-row: 1 / span 3; align-self: start; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; line-height: 26px; text-align: center;
}
#app[data-state="result"] .ss-label { display: block; grid-column: 2; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
#app[data-state="result"] .ss-word { display: block; grid-column: 2; font-size: 19px; font-weight: 600; line-height: 1.25; }
#app[data-state="result"] .ss-text { display: block; grid-column: 2; font-size: 14px; line-height: 1.5; color: var(--text-dim); }
#app[data-state="result"] .story-glance { padding-top: 14px; }
#app[data-state="result"] .story-glance h3 { margin: 0 0 4px; }
#app[data-state="result"] .glance-row { display: flex; flex-direction: column; gap: 3px; padding: 12px 0; border-top: 1px solid var(--border); }
#app[data-state="result"] .glance-k { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
#app[data-state="result"] .glance-v { display: block; margin: 0; font-size: 15px; font-weight: 600; line-height: 1.4; }
@media (max-width: 960px) {
  #app[data-state="result"] .story-glance { margin-top: 8px; border-top: 1px solid var(--border); }
  #app[data-state="result"] .story-glance h3 { margin-top: 14px; }
}
@media (max-width: 640px) {
  .wod-card { width: 100% !important; max-width: none; box-sizing: border-box; }
}

/* ---------- Map home: no suggestion chips, the card carries the suggestion ---------- */
.card-head-landing, .empty-chips-bar, .empty-chips-label { display: none !important; }
#app[data-state="landing"] .card-head { justify-content: flex-end; }

/* Word list sheet: bigger notch target */
.sheet-handle { cursor: pointer; touch-action: none; }

@media (max-width: 640px) {
  /* crowded hero: smaller buttons, more air around the title */
  .hero { padding-top: 40px; }
  .search-row { margin-top: 28px; gap: 10px; }
  .search-buttons { gap: 10px; }
  .search-buttons .btn { height: 40px; font-size: 14px; }
  .stage { margin-top: 28px; }

  /* the map home: map on top, the suggestion card underneath */
  #app[data-state="landing"] .map-stage { height: auto; display: flex; flex-direction: column; }
  #app[data-state="landing"] #map { height: 230px; flex: none; }
  #app[data-state="landing"] .map-stage .wod-card {
    position: static; width: auto !important; margin: 12px; left: auto; top: auto;
  }
  #app[data-state="landing"] .map-hint { display: none; }

  /* origin picker: no native dropdown, type or pick from the short list */
  .wordlist-filter select { display: none; }
  .origin-search-wrap { flex: 1 1 100%; position: relative; }
  .origin-search-wrap .autocomplete-list { max-height: min(28vh, 200px); overflow-y: auto; }
  .sheet-handle { padding: 14px 0; margin: 0 auto; width: 80px; background-clip: content-box; height: 4px; box-sizing: content-box; }
}
@media (max-width: 640px) {
  .input-wrap { flex: 1 1 calc(100% - 60px); }
  .trace-arrow { flex: none; width: 50px; }
}
.brand-name { position: relative; top: 1.5px; }

/* Globe controls hug the sphere: inset to its width, a short step above it */
@media (min-width: 961px) {
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-tools {
    right: max(24px, calc(50% - var(--gsize) * 0.44)); top: 30px;
  }
  html[data-view="globe"] #app[data-state="result"] .globe-actions {
    left: max(24px, calc(50% - var(--gsize) * 0.44)); top: 30px;
  }
}

.pin-hit { fill: transparent; stroke: none; }

/* Globe: fade into the page background (100%) from the stage cards / origin section down */
@media (min-width: 961px) {
  html[data-view="globe"] #app:is([data-state="result"], [data-state="landing"]) .globe-stage::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 0%, transparent) 0%, var(--bg) 55%, var(--bg) 100%);
    pointer-events: none; z-index: 1;
  }
  html[data-view="globe"] #app[data-state="result"] .globe-stage::after { top: calc(var(--gsize) * 0.30); }
  html[data-view="globe"] #app[data-state="landing"] .globe-stage::after { top: calc(var(--gsize) * 0.42); }
}
@media (min-width: 961px) {
  /* the faded-out lower half of the sphere must not stretch the page */
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-stage { --pad: calc(var(--gsize) * 0.0652 - 10px); padding-top: var(--pad); margin-top: calc(var(--pad) * -1); height: calc(var(--gsize) * 0.74 + var(--pad)); overflow: visible; clip-path: inset(-400px -50vw 0 -50vw); }
  html[data-view="globe"] #app[data-state="result"] #result-area { margin-top: calc(var(--gsize) * -0.44); }
  html[data-view="globe"] #app[data-state="landing"] .origin-browse { margin-top: calc(var(--gsize) * -0.19); }
  html[data-view="globe"] #app[data-state="landing"] .stage { padding-bottom: 56px; }
}

/* Globe result: stage cards are separate cards again */
@media (min-width: 961px) {
  html[data-view="globe"] #app[data-state="result"] .panel {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px;
    border: 0; border-radius: 0; overflow: visible; background: transparent; box-shadow: none;
  }
  html[data-view="globe"] #app[data-state="result"] .stop-row {
    border: 1px solid var(--border); border-radius: 12px; background: var(--card);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  }
  html[data-view="globe"] #app[data-state="result"] .stop-row + .stop-row { border-left: 1px solid var(--border); }
  html[data-view="globe"] #app[data-state="result"] .stop-row:hover,
  html[data-view="globe"] #app[data-state="result"] .stop-row.selected {
    border: 1px solid var(--accent); border-radius: 12px; background: var(--selected);
  }
}

/* Map and Globe share one page frame on desktop, so switching views moves nothing */
@media (min-width: 961px) {
  #app[data-state="result"] .hero-title { display: none; }
  #app[data-state="result"] .result-hero { display: block; text-align: center; }
  #app[data-state="result"] .route-chips:not([hidden]) {
    display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px; margin-top: 22px;
  }
  #app:is([data-state="landing"], [data-state="result"]) .stage { margin-top: 76px; }
}
@media (max-width: 640px) {
  html[data-view="globe"] #app[data-state="landing"] .stage { margin-top: 28px; }
}

/* Desktop: globe controls sit exactly where the map card's controls are */
@media (min-width: 961px) {
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-tools {
    top: 76px; right: calc(50% - 515px);
  }
  html[data-view="globe"] #app[data-state="result"] .globe-actions { top: 76px; left: calc(50% - 515px); }
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-host { position: relative; top: 10px; }
  html[data-view="globe"] #app[data-state="result"] .related-words,
  html[data-view="globe"] #app[data-state="result"] #result-area { position: relative; z-index: 10; }
}
@media (min-width: 961px){ .globe-actions{ gap: 8px; } }

/* Nothing of the globe may leak past the footer (desktop globe view) */
@media (min-width: 961px) {
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) { overflow-y: clip; overflow-x: clip; }
  html[data-view="globe"] .site-footer { position: relative; z-index: 12; background: var(--bg); }
}

/* Globe -> map: the globe sinks back down and fades, then the map loads in */
@keyframes globe-out {
  0% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(46px) scale(0.93); }
}
html.view-leaving-globe #globe-stage .globe-host { animation: globe-out 0.42s cubic-bezier(.4,0,.8,.4) both; }

/* Stage cards sit in the same place in Map and Globe view (desktop results):
   same width, and the same distance below the top of the map/globe area. */
@media (min-width: 961px) {
  html[data-view="globe"] #app[data-state="result"] #result-area {
    margin-top: calc(509px - var(--gsize) * 0.74);
    max-width: 1108px; padding: 0 16px;
  }
  html[data-view="globe"] #app[data-state="result"] #related-words {
    max-width: 1108px; padding: 0 16px; width: 100%; margin-left: auto; margin-right: auto; box-sizing: border-box;
  }
  html[data-view="globe"] #app[data-state="result"] .globe-stage::after { top: calc(509px + var(--pad) - 150px); }
}
@media (min-width: 961px) {
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-stage { clip-path: inset(-400px -50vw 0 -50vw); }
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-host { clip-path: inset(-400px -50vw 8px -50vw); }
}

/* Desktop: 90% map, cards a little higher */
@media (min-width: 961px) {
  .map-stage { height: 400px; }
  #app[data-state="result"] .result-area { margin-top: 8px; }
}

/* ===== Desktop: one frame for Map and Globe (no map container, faded edges) ===== */
@media (min-width: 961px) {
  #app:is([data-state="landing"], [data-state="result"]) .stage {
    --gsize: min(1080px, 72vw);
    max-width: none; width: 100%; padding: 0 0 48px; margin-top: 76px; overflow-x: clip;
  }
  #app:is([data-state="landing"], [data-state="result"]) :is(#result-area, #related-words, #origin-browse) {
    width: 100%; max-width: 1108px; padding-left: 16px; padding-right: 16px; margin-left: auto; margin-right: auto; box-sizing: border-box;
  }
  #app[data-state="result"] #result-area { margin-top: -11px; position: relative; z-index: 10; }
  #app[data-state="result"] .origin-sentence { display: none; }
  #app[data-state="landing"] #origin-browse { margin-top: 28px; position: relative; z-index: 2; }

  /* Map: no card, the map fades out at its limits */
  .map-card { border: 0; background: transparent; border-radius: 0; overflow: visible; height: 520px; position: relative; }
  .card-head {
    position: absolute; top: 11px; left: calc(50% - 515px); right: calc(50% - 515px); z-index: 8;
    min-height: 0; padding: 0; border: 0; background: transparent; justify-content: space-between; gap: 12px;
  }
  #app[data-state="landing"] .card-head { justify-content: flex-end; }
  .map-stage { position: static; height: auto; background: transparent; }
  #map {
    position: absolute; left: 50%; top: 0; transform: translateX(-50%);
    width: min(1076px, calc(100% - 32px)); height: 520px;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent), linear-gradient(to bottom, transparent, #000 8%, #000 76%, transparent);
    -webkit-mask-composite: source-in;
            mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent), linear-gradient(to bottom, transparent, #000 8%, #000 76%, transparent);
            mask-composite: intersect;
  }
  .map-stage .map-hint, .map-stage .tray { display: none !important; }

  /* Globe: same 520px box; controls at the same spots as the map's */
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-stage {
    height: calc(520px + var(--pad));
  }
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-stage::after {
    top: calc(var(--pad) + 300px);
  }
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-tools { top: calc(var(--pad) + 11px); }
  html[data-view="globe"] #app[data-state="result"] .globe-actions { top: calc(var(--pad) + 11px); }

  /* "Try this word": one spot in both views */
}
@media (min-width: 961px) {
  html[data-view="globe"] #app[data-state="result"] #result-area { margin-top: -11px; }
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-host { clip-path: inset(-400px -50vw 40px -50vw); }
}

@media (min-width: 961px) {
  #app[data-state="landing"] .wod-card,
  html[data-view="globe"] #app[data-state="landing"] .wod-card {
    position: absolute; left: max(24px, calc(50% - 600px)); top: 76px; z-index: 9;
  }
}
/* Map drag: never select text or light up pins */
#map, #map * { user-select: none; -webkit-user-select: none; }
.map-stage.panning .pin-group, .map-stage.panning * { pointer-events: none; }
.map-stage.panning { cursor: grabbing; }
.map-stage.panning .pin-group.active .pin-halo { display: none; }
/* Map -> globe: the map fades away slowly */
html.view-leaving-map #map { opacity: 0; transition: opacity 0.42s ease; }

/* The desktop map is centred with translateX(-50%): its animation must keep that offset */
@keyframes map-in-centered {
  0% { opacity: 0; transform: translateX(-50%) scale(0.97); filter: blur(3px); }
  100% { opacity: 1; transform: translateX(-50%); filter: none; }
}
@media (min-width: 961px) {
  html.view-to-map #map { animation: map-in-centered 0.6s ease both; }
}

/* Desktop: the headline area, search row and map/globe start at the same place on the homepage and on results */
@media (min-width: 961px) {
  #app[data-state="landing"] .hero-title { height: 88px; display: flex; align-items: center; justify-content: center; }
  #app[data-state="landing"] .hero { padding-bottom: 58px; }
}

.footer-count-num { color: var(--accent-text); font-weight: 600; }

/* Promote the animated layers so the page underneath is not repainted every frame */
html.view-to-globe #globe-stage .globe-host, html.view-leaving-globe #globe-stage .globe-host { will-change: transform, opacity; }
html.view-leaving-map #map, html.view-to-map #map { will-change: opacity; }

/* Phones and tablets, globe view: "Try this word" comes after the globe, like under the map */
@media (max-width: 960px) {
  html[data-view="globe"] #globe-stage .wod-card { order: 5; flex: 0 0 100%; width: 100% !important; max-width: none; margin-top: 8px; }
}

/* Phones and tablets: show the word headline and "Today it means" line on results too
   (the desktop-only rule above left them hidden at 960px and below). */
@media (max-width: 960px) {
  #app[data-state="result"] .result-hero { display: block; text-align: center; padding: 14px 16px 0; }
}

/* ===== Phones and tablets: the same frame idea as desktop ===== */
/* One fixed-size map/globe area, controls pinned to its top, the map fading at its
   edges (no card), and a headline slot that is the same height on the homepage and
   on results, so switching view or page never moves anything. */
@media (max-width: 960px) {
  #app { --viz: min(350px, 92vw); --ctl: 52px; --foot: 48px; }

  /* headline slot */
  #app[data-state="landing"] .hero-title { height: 112px; display: flex; align-items: center; justify-content: center; }
  #app[data-state="result"] .hero-title { display: none; }
  #app[data-state="result"] .result-hero {
    display: flex; flex-direction: column; justify-content: center; height: 112px; padding: 0; overflow: hidden;
  }
  #app[data-state="result"] .hero-meaning {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .search-row, #app[data-state="result"] .search-row { margin-top: 16px; }

  /* stage frame */
  #app:is([data-state="landing"], [data-state="result"]) .stage {
    display: block; max-width: 760px; margin: 20px auto 0; padding: 0 16px 32px;
  }
  .map-card, .globe-stage {
    position: relative; height: calc(var(--ctl) + var(--viz) + var(--foot));
    border: 0; border-radius: 0; background: transparent; overflow: visible; margin: 0;
  }
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-stage {
    display: block; height: calc(var(--ctl) + var(--viz) + var(--foot)); overflow: visible; margin: 0;
  }

  /* controls: same spots in both views */
  .card-head {
    position: absolute; top: 0; left: 0; right: 0; z-index: 8; display: flex; flex-wrap: nowrap;
    align-items: center; justify-content: space-between; gap: 8px; padding: 0; border: 0; min-height: 0; background: transparent;
  }
  .card-tools { width: auto; margin-left: auto; flex: none; }
  html[data-view="globe"] #app[data-state="result"] .globe-actions { display: flex; position: absolute; top: 0; left: 0; margin: 0; z-index: 8; }
  html[data-view="globe"] .globe-stage .globe-tools { display: contents; }
  html[data-view="globe"] .globe-stage .globe-tools .view-toggle { position: absolute; top: 0; right: 0; margin: 0; z-index: 8; }
  html[data-view="globe"] .globe-stage .globe-tools .globe-caption {
    position: absolute; left: 0; right: 0; bottom: 0; margin: 0; display: flex; justify-content: center; flex: none;
  }

  /* map: no container, fades at its edges */
  .map-stage { position: static; height: auto; background: transparent; }
  #map {
    position: absolute; left: 0; right: 0; top: var(--ctl); width: auto; height: var(--viz);
    -webkit-mask-image: linear-gradient(to right, transparent, #000 7%, #000 93%, transparent), linear-gradient(to bottom, transparent, #000 9%, #000 74%, transparent);
    -webkit-mask-composite: source-in;
            mask-image: linear-gradient(to right, transparent, #000 7%, #000 93%, transparent), linear-gradient(to bottom, transparent, #000 9%, #000 74%, transparent);
            mask-composite: intersect;
  }
  .map-stage .map-hint, .map-stage .tray { display: none !important; }

  /* globe in the same box */
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-host {
    position: absolute; top: var(--ctl); left: 0; right: 0; margin: 0 auto; width: var(--viz); --size: var(--viz); order: 0;
  }
  html[data-view="globe"] .globe-stage::after { display: none; }

  /* Try this word: after the area, in both views */
  #app[data-state="landing"] .wod-card, html[data-view="globe"] #app[data-state="landing"] .wod-card {
    position: static; display: block; width: 100%; max-width: none; margin: 8px 0 0; left: auto; top: auto; order: 0;
  }
}
@media (max-width: 960px) {
  html[data-view="globe"] #app .globe-stage .globe-tools .globe-caption {
    position: absolute; left: 0; right: 0; bottom: 0; top: auto; margin: 0; justify-content: center;
  }
}
@media (max-width: 960px) {
  #map { left: 0; right: auto; width: 100%; }
  .map-card { overflow-x: clip; }
}
@media (max-width: 960px) {
  html[data-view="globe"] #app .globe-stage { margin: 0 !important; padding: 0 !important; top: 0; }
  html[data-view="globe"] #app .globe-stage .globe-tools .view-toggle { top: 0 !important; }
  .card-head { top: 0 !important; }
  #app .map-card { margin: 0 !important; }
}
@media (max-width: 960px) {
  html[data-view] #app:is([data-state="landing"], [data-state="result"]) .stage { margin-top: 20px !important; padding-top: 0 !important; }
}
@media (max-width: 960px) { #app .card-head { padding: 0 !important; align-items: flex-start !important; } .card-tools { align-items: flex-start; } }

/* Phones and tablets: pill moves to the top-left; the daily word sits right under the map/globe */
@media (max-width: 960px) {
  #app { --foot: 0px; }
  html[data-view="globe"] #app .globe-stage .globe-tools .globe-caption {
    top: 0 !important; bottom: auto !important; left: 0 !important; right: auto !important; justify-content: flex-start !important;
  }
  html[data-view="globe"] #app[data-state="result"] .globe-stage .globe-tools .globe-caption { top: var(--ctl) !important; }
  #app[data-state="landing"] .wod-card, html[data-view="globe"] #app[data-state="landing"] .wod-card { margin-top: 0; }
}

/* ---------- Loading skeleton ---------- */
.skeleton { display: none; }
#app.is-loading .skeleton { display: block; max-width: 1108px; width: 100%; margin: 0 auto; padding: 0 16px; box-sizing: border-box; }
#app.is-loading #wod-card, #app.is-loading #origin-browse, #app.is-loading #result-area, #app.is-loading #related-words { display: none !important; }
.skeleton-label { margin: 0 0 14px; text-align: center; font-size: 14px; color: var(--text-dim); }
.skeleton-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.sk-card { border: 1px solid var(--border); border-radius: 12px; background: var(--card); padding: 18px; display: flex; flex-direction: column; gap: 10px; min-height: 150px; }
.sk { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--hair), var(--accent-soft), var(--hair)); background-size: 200% 100%; animation: sk-shimmer 1.3s linear infinite; }
.sk-circle { width: 24px; height: 24px; border-radius: 50%; }
.sk-l1 { width: 55%; height: 22px; }
.sk-l2 { width: 40%; height: 13px; }
.sk-l3 { width: 85%; height: 13px; }
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
@media (min-width: 961px) { #app.is-loading .skeleton { margin-top: 24px; } }
#app.is-loading #map, #app.is-loading .globe-host { opacity: 0.45; transition: opacity 0.2s; }

@media (max-width: 640px) {
  #app[data-state="landing"] .hero-title { height: 100px; }
  #app[data-state="result"] .result-hero { height: 100px; }
}

/* Phones: the text above the stage cards has a fixed size so the cards never jump between words */
@media (max-width: 640px) {
  .hero { padding-top: 0; }
  #app[data-state="landing"] .hero-title { height: 88px; }
  #app[data-state="result"] .result-hero { height: 90px; }
  #app[data-state="result"] .origin-sentence {
    height: 94px; margin: 0 0 14px; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  }
  #app.is-loading .skeleton-label { height: 94px; margin: 0 0 14px; display: flex; flex-direction: column; gap: 10px; justify-content: center; text-align: left; }
  #app.is-loading .skeleton-label::after { content: ""; height: 56px; border-radius: 6px; background: linear-gradient(90deg, var(--hair), var(--accent-soft), var(--hair)); background-size: 200% 100%; animation: sk-shimmer 1.3s linear infinite; }
}

/* Desktop: the skeleton occupies exactly the place and size of the real stage cards */
@media (min-width: 961px) {
  #app.is-loading .skeleton { margin-top: -11px; position: relative; z-index: 10; }
  #app.is-loading .skeleton-label { position: absolute; left: 0; right: 0; top: -34px; margin: 0; }
  #app.is-loading .skeleton .sk-card { height: 189px; min-height: 189px; box-sizing: border-box; }
}

/* Desktop globe: the globe ends well above the stage edge, so no hairline of it shows under the cards */
@media (min-width: 961px) {
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-host { clip-path: inset(-400px -50vw 36px -50vw) !important; }
}
@media (min-width: 961px) {
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-stage { clip-path: inset(-400px -50vw 2px -50vw) !important; }
}
@media (min-width: 961px) {
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-stage {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 90px), transparent calc(100% - 14px));
            mask-image: linear-gradient(to bottom, #000 calc(100% - 90px), transparent calc(100% - 14px));
  }
}

/* Phones: smaller rotation pill, always above the globe; a little more air under the header */
@media (max-width: 640px) {
  .pill-btn { height: 32px; padding: 0 4px 0 11px; font-size: 11px; gap: 6px; }
  .pill-icon { width: 24px; height: 24px; }
  html[data-view="globe"] #app .globe-stage .globe-tools .globe-caption { z-index: 9; }
  .hero { padding-top: 4px; }
}
@media (max-width: 640px) {
  .hero { padding-top: 0; }
  #app[data-state="landing"] .hero-title { height: 98px; }
  #app[data-state="result"] .result-hero { height: 98px; }
  #app[data-state="result"] .result-word { font-size: 30px; margin: 2px 0; }
  #app[data-state="result"] .hero-meaning { font-size: 15px; line-height: 1.3; }
}

@media (max-width: 640px) {
  #app[data-state="landing"] .hero-title { height: 110px; }
  #app[data-state="result"] .result-hero { height: 110px; }
  #app[data-state="result"] .hero-meaning { font-size: 14px; line-height: 1.3; -webkit-line-clamp: 3; }
}

/* Globe zoom: buttons on desktop, pinch on phones */
.globe-zoom { display: inline-flex; gap: 6px; margin-right: 8px; }
@media (max-width: 640px) { .globe-zoom { display: none; } }
.globe-svg { touch-action: pan-y; }

.globe-host.is-zoomed {
  -webkit-mask-image: radial-gradient(closest-side, #000 84%, transparent 100%);
          mask-image: radial-gradient(closest-side, #000 84%, transparent 100%);
}

/* Zoom buttons live in the left cluster, outside the globe's face (desktop) */
@media (min-width: 961px) {
  .globe-stage .globe-zoom { display: none; }
  html[data-view="globe"] #app:is([data-state="landing"], [data-state="result"]) .globe-stage .globe-zoom {
    display: inline-flex; position: absolute; z-index: 8; margin: 0; gap: 8px;
    left: calc(50% - 515px); top: calc(var(--pad) + 11px);
  }
  html[data-view="globe"] #app[data-state="result"] .globe-stage .globe-zoom { left: calc(50% - 515px + 157px); }
  .globe-zoom .icon-btn { height: 36px; width: 36px; background: var(--card); }
}

/* ===== Identical, fixed-size controls in Map and Globe view ===== */
/* Share card / link / view toggle: fixed widths so bold text or label changes never shift anything */
#share-btn, #share-btn-globe { width: 100px; padding: 0; justify-content: center; }
.view-toggle button { width: 84px; justify-content: center; padding: 0; }
.view-toggle button > span:last-child { white-space: nowrap; }
@media (max-width: 640px) {
  #share-btn, #share-btn-globe { width: 96px; }
  .view-toggle button { width: 76px; }
}
@media (min-width: 961px) {
  /* zoom / reset: same three buttons, same spot, in both views */
  #app[data-state="landing"] .result-only-tools { display: inline-flex; }
  .toolbar-divider { display: none; }
  #map-card .zoom-controls {
    position: absolute; left: 0; top: 0; display: inline-flex; gap: 8px;
  }
  #app[data-state="result"] #map-card .zoom-controls { left: 156px; }
  #map-card .zoom-controls .icon-btn.small, .globe-zoom .icon-btn { width: 36px; height: 36px; background: var(--card); }
  html[data-view="globe"] #app[data-state="result"] .globe-stage .globe-zoom { left: calc(50% - 515px + 156px); }
  .globe-zoom { gap: 8px; }
}
.head-actions, .globe-actions { gap: 8px !important; }

/* ===== Word pages: the result view for one word ===== */
.back-wrap { display: flex; justify-content: center; margin-bottom: 18px; }
.back-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 99px; background: var(--card);
  color: var(--text-dim); font-size: 13px; font-weight: 600; text-decoration: none; position: relative; z-index: 5; pointer-events: auto;
}
.back-pill:hover { border-color: var(--accent); color: var(--accent-text); }
[data-page="word"] .search-row, [data-page="word"] #message, [data-page="word"] #hint { display: none !important; }
[data-page="word"] .hero { padding-top: 24px; }
[data-page="word"] #result-hero { display: block; }
@media (max-width: 960px) { [data-page="word"] .hero { padding-top: 14px; } }
/* The "where does the word come from" sentence opens the full story on desktop, where the line under the
   map is hidden; on phones and tablets the line under the map is the one shown. */
.story-question { margin: 0 0 14px; font-size: 16px; line-height: 1.6; color: var(--text); }
.story-question .origin-question { color: var(--accent-text); font-weight: 600; }
@media (max-width: 960px) { .story-question { display: none; } }
[data-page="word"] #panel:empty { min-height: 160px; } /* holds the stage cards' place until they are drawn */
@media (max-width: 640px) {
  #app[data-state="result"] .hero-meaning { font-size: 13px; line-height: 1.3; }
}

/* "Play the Game" in the header: an outlined pill so it reads as an action, not a plain link */
.header-link.header-play { padding: 6px 15px; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent-text); font-weight: 600; transition: background 0.12s, color 0.12s; }
.header-link.header-play:hover { background: var(--accent-soft); color: var(--accent-text); }
.header-play[aria-current="page"] { background: var(--accent-soft); }
@media (max-width: 640px) {
  .header-link.header-play { display: inline-flex; align-items: center; height: 34px; box-sizing: border-box; font-size: 14px; line-height: 1; padding: 0 14px; }
  .hp-long { display: none; }
}

/* One-time tip under the "Play the Game" button (hint.js) */
.play-tip { position: absolute; z-index: 20; width: min(290px, calc(100vw - 24px)); padding: 14px 34px 14px 16px; border: 1px solid var(--accent); border-radius: 14px; background: var(--card); box-shadow: 0 14px 40px var(--shadow); display: grid; gap: 3px; font-size: 14px; line-height: 1.45; color: var(--text-dim); opacity: 0; transform: translateY(-6px); transition: opacity 0.25s ease, transform 0.25s ease; pointer-events: none; }
.play-tip.show { opacity: 1; transform: none; pointer-events: auto; }
.play-tip b { font-size: 15px; font-weight: 650; color: var(--accent-text); }
.play-tip::before { content: ""; position: absolute; top: -7px; right: var(--arrow, 24px); width: 12px; height: 12px; background: var(--card); border-top: 1px solid var(--accent); border-left: 1px solid var(--accent); transform: rotate(45deg); }
.play-tip-x { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: transparent; font-size: 18px; line-height: 1; color: var(--text-dim); cursor: pointer; }
.play-tip-x:hover { background: var(--accent-soft); color: var(--accent-text); }
@media (prefers-reduced-motion: reduce) { .play-tip { transition: none; } }
.play-tip-cta { justify-self: start; margin-top: 6px; font-size: 14.5px; font-weight: 650; color: var(--accent-text); text-decoration: none; }
.play-tip-cta:hover { text-decoration: underline; }

/* Footer "Feedback" button and its form (feedback.js) */
.footer-feedback { padding: 0; border: 0; background: none; font: inherit; line-height: inherit; color: var(--text-dim); cursor: pointer; }
.footer-feedback:hover { color: var(--accent-text); }
.site-footer .footer-feedback { min-height: 0; }
@media (max-width: 640px) { .site-footer .footer-feedback { display: inline-flex; align-items: center; min-height: 44px; } }
.fb-card { max-width: 480px; }
.fb-intro { margin: 0 0 14px; color: var(--text-dim); line-height: 1.5; }
.fb-form { display: grid; gap: 10px; position: relative; }
.fb-text, .fb-mail { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: 15px; resize: vertical; }
.fb-text:focus, .fb-mail:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fb-mail::placeholder, .fb-text::placeholder { font-size: 14px; }
.fb-mail::placeholder { font-size: 13.5px; }
.fb-note { margin: 0; font-size: 12.5px; color: var(--text-dim); }
.fb-count { justify-self: end; margin-top: -6px; font-size: 12px; color: var(--text-dim); }
.fb-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fb-done { padding: 6px 0 4px; }
.fb-done .btn { margin-top: 4px; }
