/* ===================================================================
   RingFence styles: one file for the whole site.
   - Shared: brand tokens and base resets.
   - Marketing pages and blog: scoped to <body class="site">.
   - The app (/app/): scoped to <body class="app">.
   Scoping keeps the two from affecting each other (e.g. .btn and .card
   mean different things in each).
   =================================================================== */

:root {
  color-scheme: light;
  --paper: #E8EDE6;
  --sheet: #F8FAF6;
  --ink: #1B2932;
  --ink-soft: #4C5C63;
  --contour: #9BB0A1;
  --marker: #0E5E6F;
  --marker-dark: #0B4B59;
  --flag: #E0A800;
  --flag-wash: #FBF0C8;
  --font: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
  --danger: #A4282A;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
:focus-visible { outline: 3px solid var(--flag); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ===================================================================
   Marketing pages and blog (body.site)
   =================================================================== */
body.site {
  background: var(--paper); color: var(--ink);
  font: 400 17px/1.65 var(--font);
  min-height: 100vh; display: flex; flex-direction: column;
}
.site a { color: var(--marker); text-underline-offset: 2px; }
.site a:hover { color: var(--marker-dark); }
.site img, .site svg { max-width: 100%; }
/* ---------- header ---------- */
.site .bar {
  display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap;
  padding: 14px var(--gutter); border-bottom: 1px solid var(--contour);
}
.site .bar nav { margin-left: auto; }
.site .wordmark {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none;
}
.site .wordmark .wm-text { display: flex; flex-direction: column; line-height: 1.05; }
.site .wordmark .wm-by { font-size: .68rem; font-weight: 600; letter-spacing: .02em; color: var(--ink-soft); }
.site .bar nav { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; font-size: .95rem; font-weight: 600; }
.site .bar nav a { color: var(--ink); text-decoration: none; }
.site .bar nav a:hover, .site .bar nav a[aria-current="page"] { color: var(--marker); text-decoration: underline; }
.site .btn {
  display: inline-block; border: 1.5px solid var(--ink); border-radius: 6px; padding: 9px 16px;
  font-weight: 700; font-size: .95rem; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.site .btn.primary { background: var(--marker); border-color: var(--marker); color: #fff; }
.site .btn.primary:hover { background: var(--marker-dark); color: #fff; }
/* ---------- layout ---------- */
.site main { flex: 1; width: 100%; }
.site .wrap { max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter); }
.site .prose { max-width: 720px; }
.site .hero { padding: clamp(40px, 7vw, 88px) 0 clamp(28px, 4vw, 48px); border-bottom: 1px solid var(--contour); }
.site .eyebrow { font-size: .95rem; font-weight: 700; color: var(--marker); margin: 0 0 10px; }
.site h1 { font-size: clamp(2rem, 4.6vw, 3.3rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.07; margin: 0 0 18px; max-width: 20ch; }
.site .lede { font-size: clamp(1.08rem, 1.6vw, 1.28rem); color: var(--ink-soft); max-width: 60ch; margin: 0 0 26px; }
.site .hero .actions { display: flex; gap: 12px; flex-wrap: wrap; }
.site .hero .btn { padding: 12px 22px; font-size: 1rem; }
.site section.block { padding: clamp(36px, 5vw, 64px) 0; border-bottom: 1px solid var(--contour); }
.site h2 { font-size: clamp(1.45rem, 2.6vw, 2rem); font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; margin: 1.6em 0 .5em; }
.site section.block > .wrap > h2:first-child, .site .prose > h2:first-child { margin-top: 0; }
.site h3 { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em; margin: 1.4em 0 .3em; }
.site p, .site ul, .site ol { margin: 0 0 1em; }
.site li { margin-bottom: .35em; }
.site strong { font-weight: 700; }
.site code { font-size: .88em; background: var(--sheet); border: 1px solid var(--contour); padding: 1px 5px; border-radius: 4px; }
.site pre { background: var(--ink); color: var(--sheet); padding: 16px; border-radius: 6px; overflow-x: auto; font-size: .85rem; line-height: 1.5; }
.site pre code { background: none; border: 0; padding: 0; color: inherit; }
/* ---------- components ---------- */
.site .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.site .grid-top { align-items: start; }
.site .price-note { margin-top: 12px; }
.site .cta-row { margin-top: 22px; }
.site .card { background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 8px; padding: 20px 22px; }
.site .card h3 { margin-top: 0; }
.site .card p:last-child { margin-bottom: 0; }
.site .card .num { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; color: var(--marker); line-height: 1; margin-bottom: 6px; }
.site .table-wrap { overflow-x: auto; margin: 0 0 1.4em; }
.site table { border-collapse: collapse; width: 100%; background: var(--sheet); font-size: .95rem; }
.site .table-wrap table { min-width: 640px; }
.site th, .site td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--contour); vertical-align: top; }
.site thead th { border-bottom: 1.5px solid var(--ink); font-weight: 800; }
.site td.yes { color: var(--marker); font-weight: 700; }
.site td.no { color: var(--ink-soft); }
.site .callout { background: var(--flag-wash); border-left: 4px solid var(--flag); padding: 16px 20px; border-radius: 0 6px 6px 0; margin: 0 0 1.4em; }
.site .callout p:last-child { margin-bottom: 0; }
.site .cta {
  background: var(--marker); color: #fff; border-radius: 10px; padding: clamp(24px, 4vw, 40px);
  margin: clamp(32px, 5vw, 56px) 0; display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.site .cta h2 { color: #fff; margin: 0 0 6px; }
.site .cta p { margin: 0; color: #D7E7EA; max-width: 52ch; }
.site .cta .btn { background: var(--flag); border-color: var(--flag); color: var(--ink); padding: 12px 22px; }
.site .cta .btn:hover { background: #F2C230; color: var(--ink); }
.site .price { font-size: 3.4rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.site .price small { font-size: 1rem; font-weight: 600; color: var(--ink-soft); letter-spacing: 0; }
.site .checks { list-style: none; padding: 0; }
.site .checks li { padding-left: 28px; position: relative; }
.site .checks li::before { content: ""; position: absolute; left: 4px; top: .5em; width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--marker); }
/* ---------- blog ---------- */
.site .post-meta { color: var(--ink-soft); font-size: .92rem; margin: 0 0 8px; }
.site article.post { padding: clamp(36px, 6vw, 72px) 0 0; }
.site article.post h1 { max-width: 24ch; }
.site .faq h3 { margin-top: 1.2em; }
.site .post-list { list-style: none; padding: 0; display: grid; gap: 18px; }
.site .post-list li { margin: 0; }
.site .post-list a { text-decoration: none; color: inherit; display: block; }
.site .post-list a:hover h2 { color: var(--marker); text-decoration: underline; }
.site .post-list h2 { font-size: 1.3rem; margin: 4px 0 6px; }
.site .post-list p { margin: 0; color: var(--ink-soft); }
.site .related { margin-top: 8px; }
/* ---------- footer ---------- */
.site footer { padding: 24px var(--gutter); font-size: .84rem; color: var(--ink-soft); border-top: 1px solid var(--contour); }
.site footer a { color: inherit; }
.site footer .cols { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 10px; font-weight: 600; }
.site footer p { margin: 0 0 6px; }
/* Narrow screens: logo, Demo, and Sign in share the top row; links wrap underneath. */
.site .bar-actions { display: flex; gap: 8px; }
@media (max-width: 960px) {
  .site .bar .bar-actions { order: 2; margin-left: auto; }
  .site .bar nav { order: 3; width: 100%; margin-left: 0; }
}
@media (max-width: 640px) {
  body.site { font-size: 16px; }
  .site .bar nav { gap: 4px 14px; font-size: .9rem; }
}

/* ===================================================================
   App (/app/, body.app)
   =================================================================== */
body.app {
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.app button, .app input, .app select, .app textarea { font: inherit; color: inherit; }
/* ---------- top bar ---------- */
.app .bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--contour);
}
.app .wordmark {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none;
}
.app .wordmark .wm-text { display: flex; flex-direction: column; line-height: 1.05; }
.app .wordmark .wm-by { font-size: .68rem; font-weight: 600; letter-spacing: .02em; color: var(--ink-soft); }
.app .bar nav { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.app .bar .who { color: var(--ink-soft); margin-right: 6px; }
.app .btn {
  border: 1.5px solid var(--ink); background: transparent; border-radius: 6px;
  padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: .9rem; white-space: nowrap;
}
.app .btn:hover { background: var(--sheet); }
.app .btn.primary { background: var(--marker); border-color: var(--marker); color: #fff; }
.app .btn.primary:hover { background: #0B4B59; }
.app .btn.quiet { border-color: transparent; }
.app .btn.quiet:hover { border-color: var(--contour); }
.app .btn.danger { color: var(--danger); border-color: currentColor; }
.app .btn:disabled { opacity: .5; cursor: not-allowed; }
.app main { flex: 1; padding: clamp(20px, 4vw, 40px); max-width: 1440px; width: 100%; margin: 0 auto; }
/* ---------- search ---------- */
.app .search {
  display: grid; grid-template-columns: 1fr minmax(300px, 420px); gap: 24px; align-items: center;
  padding-bottom: 28px; border-bottom: 1px solid var(--contour); margin-bottom: 28px;
}
.app h1 { font-size: clamp(1.75rem, 3.4vw, 2.6rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin: 0 0 20px; max-width: 22ch; }
.app form.fields { display: grid; grid-template-columns: minmax(220px, 3fr) minmax(150px, 1.4fr) 120px auto auto; gap: 10px; align-items: end; }
.app label { display: grid; gap: 4px; font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.app input[type=text], .app input[type=number], .app input[type=email], .app input[type=password], .app select { height: 44px; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: 6px; background: var(--sheet); width: 100%; }
/* mi / km segmented toggle: two equal halves, the selected one filled */
.app .units {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; min-width: 112px; height: 44px;
  border: 1.5px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--sheet);
}
.app .units input { position: absolute; opacity: 0; pointer-events: none; }
.app .units label {
  display: flex; align-items: center; justify-content: center; padding: 0 14px; cursor: pointer;
  color: var(--ink); font-size: .95rem; font-weight: 700; transition: background-color .15s, color .15s;
}
.app .units label + input + label { border-left: 1.5px solid var(--ink); }
.app .units label:hover { background: var(--paper); }
.app .units input:checked + label { background: var(--ink); color: var(--sheet); }
.app .units input:focus-visible + label { outline: 3px solid var(--flag); outline-offset: -3px; }
.app .samples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; font-size: .85rem; font-weight: 600; color: var(--ink); border: 1px solid orange; padding: 5px 15px; border-radius: 6px; background-color: orange; }
.app .chip {
  border: 1.5px solid var(--ink); border-radius: 999px; background: var(--sheet); color: var(--ink);
  padding: 4px 12px; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.app .chip:hover { background: var(--paper); }
.app .chip[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
.app form.fields .btn.primary { height: 44px; padding: 0 22px; }
/* the radius map: the one expressive element */
.app .map-wrap { position: relative; }
.app .map { height: 260px; border: 1.5px solid var(--ink); border-radius: 6px; background: var(--sheet); z-index: 0; }
.app .map-label {
  position: absolute; top: 10px; right: 10px; z-index: 500; pointer-events: none;
  background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 4px; padding: 2px 8px;
  font: 800 14px var(--font);
}
.app .leaflet-container { font: inherit; }
.app .notice { margin: 0 0 20px; padding: 12px 16px; border-left: 4px solid var(--flag); background: var(--sheet); max-width: 72ch; }
.app .notice.error { border-color: var(--danger); }
.app .picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
/* ---------- loading ---------- */
.app .loader { display: grid; justify-items: center; gap: 12px; padding: 24px 0 28px; }
.app .spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid var(--contour); border-top-color: var(--marker);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .app .spinner { animation-duration: 2.4s; }
}
.app .progress { width: min(360px, 100%); height: 8px; background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.app .progress-bar { height: 100%; width: 0; background: var(--marker); transition: width .2s ease-out; }
.app .loader p { margin: 0; color: var(--ink-soft); font-size: .9rem; }
.app #resultsWrap.is-stale { opacity: .35; pointer-events: none; }
.app .btn.primary:disabled { background: #A3AEA8; border-color: #A3AEA8; color: #fff; opacity: 1; cursor: progress; }
/* ---------- results ---------- */
.app .summary { font-size: 1.05rem; margin: 0 0 16px; }
.app .summary strong { font-weight: 800; }
.app .summary .tag { display: inline-block; background: var(--flag-wash); border: 1px solid var(--flag); border-radius: 4px; padding: 0 6px; font-size: .8rem; font-weight: 700; vertical-align: 2px; }
.app h2 { font-size: 1rem; font-weight: 800; margin: 0; }
.app .toolbar { display: grid; gap: 8px; margin-bottom: 8px; }
.app .tool-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.app .tool-row .spacer { flex: 1; }
/* Download and Copy boxes: identical, each keeps its options and buttons together. */
.app .tool-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; min-width: 0;
  padding: 2px 6px 6px 12px; border: 1.5px solid var(--contour); border-radius: 8px; background: var(--sheet);
}
.app .tool-box legend { padding: 0 5px; margin-left: -5px; font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
/* The two buttons in each box stay on one line together. */
.app .btn-pair { display: inline-flex; gap: 8px; flex-wrap: nowrap; }
@media (max-width: 480px) {
  .app .btn-pair { flex-wrap: wrap; }
}
/* phones: too narrow for two buttons */
.app .row-count { font-size: .95rem; font-weight: 600; color: var(--ink); }
.app .btn-reset { border-color: var(--danger); }
.app .field-max { font-weight: 500; color: var(--ink-soft); transition: color .2s; }
.app .field-max.is-flagged { color: var(--danger); font-weight: 700; }
.app .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Page-not-found banner: floats over everything (no layout shift), slides in, fades out after 30s. */
.app .nf-banner {
  position: fixed; top: 16px; left: 50%; z-index: 10000;
  width: max-content; max-width: calc(100% - 32px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px;
  padding: 12px 46px; text-align: center; font-size: .95rem; font-weight: 600; color: var(--ink);
  background: var(--flag-wash); border: 1.5px solid var(--flag); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(27, 41, 50, .22);
  opacity: 0; transform: translate(-50%, -12px); transition: opacity .6s ease, transform .6s ease;
}
.app .nf-banner.is-in { opacity: 1; transform: translate(-50%, 0); }
.app .nf-banner a { color: var(--marker); font-weight: 700; text-underline-offset: 2px; }
.app .nf-close {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent;
  font-size: 1.3rem; line-height: 1; color: var(--ink-soft); cursor: pointer;
}
.app .nf-close:hover { background: rgba(27, 41, 50, .08); color: var(--ink); }
@media (prefers-reduced-motion: reduce) {
  .app .nf-banner, .app .nf-banner.is-in { transform: translate(-50%, 0); transition: opacity .6s ease; }
}
/* Desktop: Table, Download, and Copy side by side as three equal columns.
   Inside each box the options sit on top and the two buttons below; if a column
   is too narrow for both buttons, they stack at full width instead of overflowing. */
@media (min-width: 1025px) {
  .app .toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
  .app .tool-row { align-items: stretch; }
  .app .tool-row > .tool-box { flex: 1; flex-direction: column; align-items: flex-start; }
  .app .tool-box .btn-pair { display: flex; flex-wrap: wrap; width: 100%; }
  .app .tool-box .btn-pair > .btn { flex: 1 1 auto; }
}
.app .scope { display: inline-flex; gap: 4px; align-items: center; font-size: .9rem; }
.app .scope label { display: inline-flex; flex-direction: row; gap: 4px; align-items: center; color: var(--ink); font-weight: 500; font-size: .9rem; }
.app .table-help { font-size: .82rem; color: var(--ink-soft); margin: 0 0 8px; }
.app #table { border: 1.5px solid var(--ink); border-radius: 6px; background: var(--sheet); }
.app .tabulator { font-size: .9rem; background: var(--sheet); }
.app .tabulator .tabulator-header { background: var(--paper); border-bottom: 1.5px solid var(--ink); }
.app .tabulator .tabulator-header .tabulator-col { background: var(--paper); }
.app .tabulator .tabulator-header .tabulator-col input { height: auto; border: 1px solid var(--contour); border-radius: 4px; padding: 3px 6px; background: #fff; }
.app .tabulator-row.tabulator-selected { background: var(--flag-wash) !important; }
.app .tabulator-row .tabulator-cell.tabulator-editing { outline: 2px solid var(--marker); }
.app .col-head { display: grid; gap: 4px; }
.app .col-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app .col-tools { display: inline-flex; gap: 2px; flex: none; }
.app .col-btn {
  width: 24px; height: 24px; display: grid; place-items: center; padding: 0; cursor: pointer;
  border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink-soft);
}
.app .col-btn:hover { border-color: var(--contour); background: var(--sheet); color: var(--ink); }
.app .col-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.app .col-btn svg { width: 14px; height: 14px; }
/* ---------- auth + account ---------- */
.app .card { background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 8px; padding: 28px; max-width: 420px; }
.app .card h1 { font-size: 1.8rem; }
.app .stack { display: grid; gap: 12px; }
.app .or { text-align: center; color: var(--ink-soft); font-size: .85rem; }
.app .account { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 32px; }
.app .account section { border-top: 3px solid var(--ink); padding-top: 14px; }
.app .account p { max-width: 60ch; }
.app .keys { list-style: none; padding: 0; margin: 12px 0; }
.app .keys li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--contour); }
.app .keys small { color: var(--ink-soft); display: block; }
.app .newkey { background: var(--flag-wash); border: 1.5px dashed var(--flag); padding: 12px; border-radius: 6px; word-break: break-all; }
.app .newkey { margin-top: 12px; }
.app .btn-row { display: flex; gap: 8px; }
.app h2.spaced { margin-top: 20px; }
.app code { font-size: .88em; background: var(--paper); padding: 1px 5px; border-radius: 4px; }
.app pre { background: var(--ink); color: var(--sheet); padding: 14px; border-radius: 6px; overflow-x: auto; font-size: .82rem; }
.app footer { padding: 18px clamp(16px, 4vw, 40px); font-size: .8rem; color: var(--ink-soft); border-top: 1px solid var(--contour); }
.app footer a { color: inherit; }
@media (max-width: 900px) {
  .app .search { grid-template-columns: 1fr; }
  .app .map { height: 240px; }
  .app form.fields { grid-template-columns: 1fr 1fr; }
  .app form.fields .loc { grid-column: 1 / -1; }
}
