/* Waymorphic Map tools - shared styles for /tools and every /tools/<slug> page.
   Same tokens and chrome as the landing page and the embed builder. */
:root {
  --bg: #07090d; --bg-2: #0c1016;
  --surface: rgba(255, 255, 255, .035); --surface-2: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .09); --border-2: rgba(255, 255, 255, .16);
  --fg: #f3f5f8; --muted: #8f9aab; --dim: #5f6b7c;
  --accent: #3b82f6; --accent-2: #22d3ee; --ok: #34d399; --warn: #fbbf24; --bad: #f87171;
  --grad: linear-gradient(100deg, #7dd3fc 0%, #60a5fa 45%, #a78bfa 100%);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --max: 1160px; --radius: 20px; --radius-sm: 12px; color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3 { margin: 0; letter-spacing: -.03em; line-height: 1.1; }
h1 { font-size: clamp(30px, 4.2vw, 44px); font-weight: 800; }
h2 { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #93c5fd; }
h3 { font-size: 17px; font-weight: 700; letter-spacing: -.015em; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--mono); }
/* Sections that carry .wrap set only their top and bottom padding (padding-block),
   so the side padding here survives on every screen width. */
.wrap { max-width: var(--max); margin: 0 auto; padding-inline: 24px; }
.kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #93c5fd; margin-bottom: 14px; text-decoration: none; }
.kicker::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: var(--grad); }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
[hidden] { display: none !important; }

/* ---- nav ---- */
#nav {
  position: fixed; z-index: 20; top: 14px; left: 50%; transform: translateX(-50%);
  width: min(var(--max), calc(100% - 24px)); height: 58px; padding: 0 8px 0 18px;
  display: flex; align-items: center; gap: 12px; border-radius: 999px; border: 1px solid var(--border);
  background: rgba(12, 16, 22, .7); backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 16px; letter-spacing: -.02em; white-space: nowrap; }
.logo svg { width: 28px; height: 28px; border-radius: 8px; }
.crumb { color: var(--dim); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--fg); }
.crumb b { color: var(--muted); font-weight: 500; }
#nav .spacer { margin-left: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; text-decoration: none; border: 1px solid transparent; white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.btn:active { transform: translateY(1px); }
.btn.white { background: #fff; color: #0b0f14; }
.btn.white:hover { background: #e8eef7; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 8px 30px rgba(59,130,246,.3); }
.btn.primary:hover { background: #4f8ef8; }
.btn.ghost { border-color: var(--border-2); color: var(--fg); background: var(--surface); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.units { display: inline-flex; border: 1px solid var(--border-2); border-radius: 999px; overflow: hidden; }
.units button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.units button.on { background: rgba(59,130,246,.25); color: #fff; }

/* ---- page header ---- */
.tool-head { padding: 116px 0 26px; }
.tool-head .lead { color: var(--muted); font-size: 17px; max-width: 680px; margin-top: 12px; line-height: 1.6; }
.tool-head .lead b { color: var(--fg); font-weight: 500; }

/* ---- layout ---- */
.tool { display: grid; grid-template-columns: 350px minmax(0, 1fr); gap: 20px; align-items: start; padding-bottom: 40px; }
.tool.nomap { grid-template-columns: 350px minmax(0, 1fr); }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 20px; display: grid; gap: 20px; position: sticky; top: 86px; max-height: calc(100vh - 100px); overflow: auto; scrollbar-width: thin; }
.field { display: grid; gap: 8px; }
.field > h2 { margin-bottom: 2px; }
.hint { font-size: 12.5px; color: var(--dim); line-height: 1.5; }
.hint kbd { font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-2); border-radius: 5px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-2); background: rgba(12,16,22,.65); font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s, background .15s; }
.chip:hover { color: var(--fg); }
.chip.on { color: #fff; border-color: rgba(147,197,253,.6); background: rgba(59,130,246,.25); }
.chip i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row.auto { grid-template-columns: minmax(0, 1fr) auto; }
label.in { display: grid; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
label.in input, label.in select, label.in textarea, .textbox { width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border-2); background: rgba(12,16,22,.7); color: var(--fg); font-family: var(--mono); font-size: 13px; }
label.in input[type=text], label.in input[type=search], label.in input[type=date], label.in input[type=time], label.in select { font-family: var(--font); }
label.in input:focus, label.in select:focus, label.in textarea:focus, .textbox:focus { outline: 2px solid rgba(147,197,253,.6); outline-offset: 1px; border-color: transparent; }
label.in textarea { min-height: 96px; resize: vertical; font-size: 12.5px; line-height: 1.45; }
label.in input[type=color] { padding: 2px; height: 36px; }
label.in input[type=range] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); }
label.chk { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
label.chk input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
label.chk span small { display: block; font-size: 12px; color: var(--dim); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { flex: 1 1 auto; }
.ghostlist { display: grid; gap: 4px; }
.ghostlist button { text-align: left; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--fg); font-size: 13px; cursor: pointer; line-height: 1.35; }
.ghostlist button:hover { background: var(--surface-2); border-color: var(--border-2); }
.ghostlist button small { display: block; color: var(--dim); font-size: 11.5px; }
.place { display: grid; gap: 8px; }
.place .row { grid-template-columns: minmax(0, 1fr) auto; }
.place .ghostlist:empty { display: none; }
.stops { display: grid; gap: 6px; }
.stop { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.stop .n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.stop .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop .x { border: 0; background: transparent; color: var(--dim); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.stop .x:hover { color: var(--bad); background: var(--surface-2); }
.dropzone { border: 1px dashed var(--border-2); border-radius: 12px; padding: 18px 12px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: rgba(147,197,253,.6); background: rgba(59,130,246,.08); color: var(--fg); }
.dropzone input { display: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.6); }

/* ---- stage: map and results ---- */
.stage { display: grid; gap: 16px; min-width: 0; }
.card { border: 1px solid var(--border-2); border-radius: 16px; background: #070a0f; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.45); min-width: 0; }
.bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; min-height: 44px; }
.bar i.dot { width: 10px; height: 10px; border-radius: 50%; background: #2a3441; }
.bar i.dot:nth-child(1) { background: #ff5f57; } .bar i.dot:nth-child(2) { background: #febc2e; } .bar i.dot:nth-child(3) { background: #28c840; }
.bar .file { margin-left: 8px; font-family: var(--mono); font-size: 12.5px; color: var(--dim); }
.bar .right { margin-left: auto; font-size: 12.5px; color: var(--dim); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bar .chip { padding: 4px 10px; font-size: 12px; }
.bar select { padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border-2); background: rgba(12,16,22,.7); color: var(--muted); font-size: 12px; }
#map { height: 520px; background: #f2f3f0; position: relative; }
#map.tall { height: 640px; }
.map-note { position: absolute; z-index: 2; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(12,16,22,.85); color: #fff; border: 1px solid var(--border-2); border-radius: 999px; padding: 6px 14px; font-size: 13px; pointer-events: none; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.map-pending { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; background: rgba(7,9,13,.55); color: #fff; font-size: 14px; font-weight: 500; }
.maplibregl-ctrl-attrib { font-size: 11px; }
.maplibregl-popup-content { background: #0e1218; color: var(--fg); border: 1px solid var(--border-2); border-radius: 12px; padding: 10px 12px; font: 13px/1.45 var(--font); box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: #0e1218; }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: #0e1218; }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: #0e1218; }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: #0e1218; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 2px 8px; }
.maplibregl-popup-content b { color: #fff; }
.maplibregl-popup-content small { color: var(--muted); }
.pin-label { background: rgba(12,16,22,.85); color: #fff; padding: 2px 7px; border-radius: 6px; font: 600 11.5px/1.3 var(--font); white-space: nowrap; border: 1px solid var(--border-2); transform: translateY(-4px); }

.results { display: grid; gap: 14px; }
.results:empty { display: none; }
.rcard { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 16px 18px; display: grid; gap: 10px; min-width: 0; }
.rcard > h3 { display: flex; align-items: center; gap: 10px; }
.rcard > h3 small { font-weight: 500; font-size: 12.5px; color: var(--dim); margin-left: auto; }
.rcard.bad { border-color: rgba(248,113,113,.4); }
.rcard.bad h3 { color: var(--bad); }
.rcard p { color: var(--muted); font-size: 14px; }
.rcard p b { color: var(--fg); font-weight: 500; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: rgba(12,16,22,.5); min-width: 0; }
.stat .k { font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.stat .v { font-size: 19px; font-weight: 700; letter-spacing: -.02em; margin-top: 3px; overflow-wrap: anywhere; }
.stat .v small { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat.big .v { font-size: 26px; }
.stat.mono .v { font-family: var(--mono); font-size: 14.5px; font-weight: 500; }
.stat.copy { cursor: pointer; transition: border-color .15s; }
.stat.copy:hover { border-color: var(--border-2); }
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t th { font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--dim); font-weight: 600; background: rgba(12,16,22,.5); position: sticky; top: 0; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
table.t td.mono { font-family: var(--mono); font-size: 12.5px; }
.tablewrap.scroll { max-height: 360px; overflow-y: auto; }
.legend { display: grid; gap: 6px; }
.legend .item { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.legend .item i { width: 16px; height: 16px; border-radius: 4px; flex: none; }
.legend .item.line i { height: 4px; border-radius: 2px; }
.legend .item.point i { border-radius: 50%; }
.legend .item small { color: var(--dim); margin-left: auto; }
.ramp { display: flex; height: 12px; border-radius: 6px; overflow: hidden; }
.ramp i { flex: 1; }
.ramp-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
pre.out { margin: 0; padding: 14px 16px; border-radius: 12px; background: rgba(12,16,22,.7); border: 1px solid var(--border); overflow: auto; font-size: 12.5px; line-height: 1.5; color: #d7e1ee; max-height: 320px; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--font); fill: var(--muted); }
.chart .axis { stroke: var(--border-2); }
.chart .grid { stroke: var(--border); }
.chart .area { fill: rgba(59,130,246,.25); }
.chart .line { fill: none; stroke: #60a5fa; stroke-width: 2; }
.chart .line.alt { stroke: #fbbf24; }
.chart .mark { fill: #fff; }
.progress { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 40%; background: var(--grad); animation: slide 1.2s infinite linear; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: rgba(59,130,246,.2); color: #93c5fd; }
.badge.ok { background: rgba(52,211,153,.18); color: #6ee7b7; }
.badge.warn { background: rgba(251,191,36,.18); color: #fcd34d; }
.moon { width: 120px; height: 120px; border-radius: 50%; background: #1b2230; position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px var(--border-2); margin: 0 auto; }
.sky { position: relative; width: 100%; aspect-ratio: 1; max-width: 360px; margin: 0 auto; }
.globe-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px; background: #070a0f; }
/* MapLibre puts its own class on the container, so the position is pinned here. */
.globe-pair > div, .globe-pair > div.maplibregl-map { position: relative; height: 420px; border-radius: 12px; overflow: hidden; background: #0b0f14; }
.globe-pair .tag { position: absolute; z-index: 2; left: 10px; top: 10px; background: rgba(12,16,22,.85); color: #fff; border: 1px solid var(--border-2); border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 600; }

/* ---- about, related, footer ---- */
.about { padding-block: 40px 10px; display: grid; gap: 14px; max-width: 760px; }
.about h2 { font-size: 22px; letter-spacing: -.02em; text-transform: none; color: var(--fg); font-weight: 700; margin-top: 10px; }
.about h2:first-child { margin-top: 0; }
.about p, .about li { color: var(--muted); font-size: 15px; line-height: 1.65; }
.about h3 { font-size: 16px; margin-top: 8px; color: var(--fg); }
.about .faq { display: grid; gap: 10px; }
.about ol li::marker { color: #93c5fd; font-weight: 600; }
.about ul, .about ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.about b { color: var(--fg); font-weight: 500; }
.about code { font-size: 13px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: #d9e2ee; }
.about a { color: #93c5fd; }
.related { padding-block: 40px 70px; }
.related h2 { font-size: 22px; letter-spacing: -.02em; text-transform: none; color: var(--fg); font-weight: 700; margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { display: grid; gap: 6px; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); text-decoration: none; transition: border-color .15s, background .15s, transform .15s; }
.tile:hover { border-color: var(--border-2); background: var(--surface-2); transform: translateY(-2px); }
.tile b { font-size: 15px; letter-spacing: -.01em; }
.tile span { font-size: 13px; color: var(--muted); line-height: 1.45; }
.tile small { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
footer { border-top: 1px solid var(--border); padding: 28px 0; font-size: 13.5px; color: var(--dim); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--fg); }
footer .credits { margin-left: auto; }
#toast { position: fixed; z-index: 30; left: 50%; bottom: 28px; transform: translate(-50%, 8px); opacity: 0; transition: opacity .2s, transform .2s; background: #fff; color: #0b0f14; box-shadow: 0 12px 40px rgba(0,0,0,.45); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; pointer-events: none; max-width: calc(100% - 40px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- embed section and embed mode (?embed=1) ---- */
.embedsec { padding-block: 10px 60px; display: grid; gap: 14px; max-width: 760px; }
.embedsec h2 { font-size: 22px; letter-spacing: -.02em; text-transform: none; color: var(--fg); font-weight: 700; }
.embedsec p { color: var(--muted); font-size: 15px; line-height: 1.65; }
.embedsec p b { color: var(--fg); font-weight: 500; }
.embedsec .snippet { position: relative; }
.embedsec pre { margin: 0; padding: 16px 18px; border-radius: 12px; background: rgba(12,16,22,.7); border: 1px solid var(--border); overflow: auto; font-size: 12.5px; line-height: 1.55; color: #d7e1ee; white-space: pre-wrap; overflow-wrap: anywhere; }
.embedsec .copy { position: absolute; top: 8px; right: 10px; border: 1px solid var(--border-2); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 500; cursor: pointer; }
.embedsec .copy:hover { color: #fff; background: var(--surface-2); }
.embedsec code { font-family: var(--mono); }
html.embed .tool-head, html.embed .about, html.embed .faq, html.embed .related, html.embed .embedsec, html.embed footer { display: none; }
html.embed body { background: transparent; }
html.embed .tool { padding-block: 10px; }
html.embed .wrap { padding-inline: 10px; }
html.embed .panel { position: static; max-height: none; padding: 14px; gap: 14px; }
html.embed #map, html.embed #map.tall { height: 460px; }
html.embed .card { box-shadow: none; }
@media (max-width: 960px) { html.embed #map, html.embed #map.tall { height: 380px; } }

/* ---- index page ---- */
.index-head { padding: 130px 0 30px; }
.index-head h1 { font-size: clamp(38px, 5.5vw, 68px); letter-spacing: -.04em; }
.index-head .lead { color: var(--muted); font-size: 18px; max-width: 640px; margin-top: 16px; line-height: 1.6; }
.search { display: flex; align-items: center; gap: 10px; margin-top: 26px; max-width: 560px; padding: 6px 6px 6px 16px; border-radius: 999px; border: 1px solid var(--border-2); background: rgba(12,16,22,.7); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--fg); font-size: 15px; padding: 8px 0; outline: none; }
.search .count { font-size: 12.5px; color: var(--dim); padding: 0 10px; white-space: nowrap; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.catsec { padding-block: 26px; }
.catsec h2 { font-size: 24px; letter-spacing: -.02em; text-transform: none; color: var(--fg); font-weight: 700; }
.catsec .blurb { color: var(--muted); margin: 6px 0 16px; max-width: 640px; }
.catsec[hidden] { display: none; }
.index-foot { padding-block: 40px 70px; }

@media (max-width: 960px) {
  .tool, .tool.nomap { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
  #map, #map.tall { height: 440px; }
  .globe-pair { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  #nav { height: 54px; padding: 0 6px 0 14px; }
  .crumb { display: none; }
  .tool-head { padding-top: 96px; }
  .index-head { padding-top: 100px; }
  #map, #map.tall { height: 380px; }
}
