:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis: none;
  color: #172037;
  background: #f5f6fa;
  --ink: #172037;
  --muted: #556278;
  --accent: #314ab2;
  --accent-hover: #243783;
  --tint: #edf0ff;
  --line: #dce1eb;
  --card: #fff;
  --shadow: 0 6px 20px #203b2910;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }
:where(button, a, input, select, summary):focus-visible {
  outline: 2px solid #4059c0;
  outline-offset: 3px;
}
.site-shell {
  width: min(100% - 72px, 1470px);
  margin: auto;
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 69px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -.045em;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 11px;
  background: var(--accent);
  color: #e6f8ee;
}
.brand-mark svg, .map-toolbar svg, .search-icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.site-header nav a {
  display: inline-block;
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}
.site-header nav a:hover { background: var(--tint); }
.app-main { padding: 32px 0 24px; }
.page-heading { margin-bottom: 24px; }
.page-heading h1 {
  margin: 0;
  font-size: clamp(28px, 3.3vw, 47px);
  font-weight: 760;
  letter-spacing: -.062em;
  line-height: 1.12;
}
.page-heading p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.2vw, 16px);
  line-height: 1.5;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 350px);
  gap: 18px;
  align-items: start;
}
.map-panel, .settings-card, .estimate-card, .rings-panel, .comparison-panel {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.map-panel { min-width: 0; overflow: hidden; }
.map-toolbar, .map-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
}
.map-toolbar { border-bottom: 1px solid var(--line); }
.shape-switch, .map-tools, .polygon-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.shape-switch {
  padding: 4px;
  border-radius: 11px;
  background: #f0f4ef;
}
.shape-switch button, .button, .radius-presets button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 11px;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 650;
  cursor: pointer;
}
.shape-switch button { padding-inline: 13px; }
.shape-switch button[aria-pressed="true"] {
  color: var(--accent);
  background: var(--card);
  box-shadow: 0 1px 4px #12342b22;
}
.shape-switch button:not([aria-pressed="true"]):hover, .button-quiet:hover {
  background: var(--tint);
  color: var(--accent);
}
.map-toolbar svg { width: 17px; height: 17px; }
.button-outline, .radius-presets button { border-color: var(--line); }
.button-outline { color: var(--accent); background: var(--tint); border-color: #c8d0eb; }
.button-outline:hover, .radius-presets button:hover { border-color: #82ae9c; background: var(--tint); }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { cursor: default; opacity: .47; }
.map-stage { position: relative; }
#map { height: clamp(410px, 59vh, 650px); background: #e3ebe4; }
.map-stage .leaflet-control-zoom {
  border: 0;
  border-radius: 9px;
  box-shadow: 0 2px 10px #17392c33;
}
.map-stage .leaflet-control-zoom a { color: var(--ink); }
.map-search-bar {
  position: absolute;
  top: 13px;
  left: 13px;
  z-index: 1000;
  width: min(360px, calc(100% - 74px));
}
.map-search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 45px;
  padding: 0 11px;
  border: 1px solid #c9d8ce;
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 2px 12px #203b2926;
}
.map-search-field:focus-within { border-color: #4b9a81; box-shadow: 0 0 0 2px #4059c035; }
.search-icon { width: 18px; height: 18px; color: var(--accent); }
.map-search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}
#map-search-clear {
  flex: none;
  width: 26px;
  height: 26px;
  cursor: pointer;
  border: 0;
  border-radius: 50%;
  color: var(--accent);
  background: var(--tint);
  line-height: 1;
}
.search-spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.map-search-dropdown {
  position: absolute;
  inset: calc(100% + 6px) 0 auto;
  max-height: 235px;
  margin: 0;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  list-style: none;
  background: var(--card);
  box-shadow: var(--shadow);
}
.map-search-item { display: grid; gap: 2px; border-radius: 7px; padding: 8px; cursor: pointer; }
.map-search-item:hover, .map-search-item.is-selected { background: var(--tint); }
.map-search-title { font-size: 14px; font-weight: 650; }
.map-search-subtitle, .map-search-empty { color: var(--muted); font-size: 12px; }
.map-search-empty { padding: 8px; }
.map-caption { min-height: 62px; border-top: 1px solid var(--line); }
.map-caption p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.polygon-actions { flex: none; }
.mobile-result, .mobile-share { display: none; }
.panel { display: grid; min-width: 0; gap: 14px; }
.settings-card, .estimate-card, .rings-panel, .comparison-panel { padding: 18px; }
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.panel-heading h2, .rings-panel h2, .comparison-panel h2, .about-estimates h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
  letter-spacing: -.025em;
}
.units-control { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.units-control select, .field input, .analysis-table input, .analysis-table button {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}
.field label { display: block; margin: 0 0 6px; color: var(--muted); font-size: 13px; font-weight: 650; }
.field input { width: 100%; height: 40px; padding-inline: 10px; font-size: 15px; }
.radius-input { position: relative; }
.radius-input input { height: 49px; padding-right: 44px; font-size: 21px; font-weight: 700; }
.radius-limit { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.radius-limit.is-error { color: #a3202c; font-weight: 650; }
.radius-input input[aria-invalid="true"] { border-color: #b72836; }
.radius-input span {
  position: absolute;
  inset: 0 13px 0 auto;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}
.radius-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 8px;
}
.radius-presets button { min-height: 34px; padding: 4px; white-space: nowrap; }
.radius-presets button[aria-pressed="true"] { background: var(--tint); color: var(--accent); border-color: #a0b0e7; }
.coordinates { margin: 14px 0; font-size: 13px; }
.coordinates summary { width: fit-content; color: var(--accent); cursor: pointer; font-weight: 600; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.circle-actions { display: flex; gap: 6px; }
.circle-actions .button-primary { flex: 1; }
.polygon-status { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.estimate-card { background: #edf6ef; border-color: #d5e5da; }
#result-content { transition: opacity .15s; }
#result-content.is-loading { opacity: .55; }
.result-topline { display: flex; flex-wrap: wrap; gap: 5px 10px; justify-content: space-between; align-items: baseline; }
.result-label { font-size: 14px; font-weight: 700; color: var(--accent); }
.result-shape, .result-details, .analysis-status, .panel-source { color: var(--muted); font-size: 12px; line-height: 1.5; }
.number {
  margin: 9px 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: clamp(32px, 3vw, 46px);
  font-weight: 760;
  letter-spacing: -.065em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.shape-measures { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 14px 0 9px; }
.shape-measures div { min-width: 0; display: grid; gap: 3px; padding: 8px; border-radius: 8px; background: #fff9; }
.shape-measures div:last-child { grid-column: 1 / -1; grid-template-columns: 1fr auto; align-items: baseline; }
.shape-measures span { color: var(--muted); font-size: 11px; }
.shape-measures strong { color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.result-details { margin: 0; }
.result-share { margin-top: 16px; }
.result-share p { margin: 0 0 7px; font-size: 13px; font-weight: 700; }
.share-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.share-actions button { min-height: 42px; }
.share-actions svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.share-fallback { grid-column: 1 / -1; padding-top: 4px; }
.share-fallback label { display: block; font-size: 13px; font-weight: 650; }
.share-fallback textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  resize: vertical;
}
.share-actions .share-fallback p { margin: 4px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; }
.compare-action { margin-top: 7px; padding-inline: 0; color: var(--accent); }
.rings-explanation { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
#rings-radius { color: var(--muted); font-size: 13px; font-weight: 600; }
#rings-table tfoot { font-weight: 750; }
#rings-table tfoot :is(th, td) { color: var(--ink); border-bottom: 0; }
.empty-result { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.warning, .alert, .errorlist {
  margin: 10px 0;
  padding: 8px 10px;
  border: 1px solid #e4cf9f;
  border-radius: 8px;
  background: #fff8e7;
  color: #664618;
  font-size: 12px;
  line-height: 1.45;
}
.errorlist { list-style: none; }
.panel-source { margin-top: 13px; padding-top: 10px; border-top: 1px solid #d5e5da; }
.analysis-status { margin: 8px 0 0; }
.comparison-panel { margin-top: 16px; }
.comparison-scroll { overflow-x: auto; }
.analysis-table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.analysis-table th, .analysis-table td { padding: 7px 8px 7px 0; text-align: left; border-bottom: 1px solid var(--line); }
.analysis-table th { color: var(--muted); }
.analysis-table input { width: min(135px, 30vw); }
.analysis-table button { margin-left: 8px; cursor: pointer; }
.comparison-panel td, .comparison-panel th { white-space: nowrap; }
.ring-label::before {
  content: "";
  display: inline-block;
  width: 10px;
  margin-right: 6px;
  vertical-align: middle;
  border-top: 2px dashed var(--ring-color);
}
.shape-handle { border: 2px solid var(--accent); border-radius: 50%; background: #fff; box-shadow: 0 1px 5px #17392c66; }
.map-center-marker {
  border: 3px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 2px, var(--accent) 3px 6px, #c5e6d7 7px 8px, var(--accent) 9px);
  box-shadow: 0 1px 6px #17392c99;
}
.vertex-handle, .radius-handle { cursor: grab; }
.vertex-handle.is-selected { background: var(--accent); border-color: #fff; outline: 2px solid var(--accent); }
.radius-handle::before, .edge-handle::before {
  content: "+";
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--accent);
  font: 700 14px/1 system-ui, sans-serif;
}
.edge-handle { border: 1px dashed var(--accent); cursor: pointer; }
.shape-handle:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.about-estimates {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 20px 2px 0;
}
.about-estimates p { max-width: 65ch; margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.about-estimates a { font-size: 13px; font-weight: 650; }
.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  border-top: 1px solid var(--line);
  padding: 14px 0 24px;
  color: var(--muted);
  font-size: 12px;
}
.article { max-width: 760px; padding: 33px 0 42px; }
.article .back { font-size: 13px; }
.article h1 { margin: 24px 0 12px; font-size: clamp(29px, 4vw, 44px); letter-spacing: -.055em; }
.article h2 { margin-top: 25px; font-size: 21px; letter-spacing: -.025em; }
.article p { color: var(--muted); line-height: 1.65; }
.article .lead { font-size: 18px; }
.article .metadata { font-size: 13px; }

@media (max-width: 970px) {
  .site-shell { width: calc(100% - 36px); }
  .workspace { grid-template-columns: minmax(0, 1fr) 295px; gap: 12px; }
  .map-caption { flex-wrap: wrap; }
  .polygon-actions { margin-left: auto; }
}
@media (max-width: 760px) {
  .site-shell { width: calc(100% - 24px); }
  .site-header { min-height: 56px; }
  .app-main { padding-top: 20px; }
  .page-heading { margin-bottom: 15px; }
  .page-heading p { margin-top: 6px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .map-toolbar, .map-caption { gap: 4px; padding: 7px; }
  .map-toolbar { flex-wrap: wrap; }
  .map-caption p { flex-basis: 100%; padding: 4px; }
  .mobile-share:not([hidden]) { display: block; padding: 0 10px 10px; }
  .result-share { display: none; }
  .map-toolbar .desktop-label { display: none; }
  .shape-switch { gap: 2px; padding: 3px; }
  .shape-switch button, .map-tools .button { gap: 4px; padding-inline: 6px; font-size: 12px; }
  .map-toolbar svg { width: 14px; height: 14px; }
  #map { height: clamp(290px, 47svh, 490px); }
  .mobile-result:not(:empty) {
    display: block;
    position: absolute;
    z-index: 1000;
    bottom: 44px;
    left: 50%;
    width: max-content;
    max-width: calc(100% - 24px);
    transform: translateX(-50%);
    padding: 8px 11px;
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    color: var(--ink);
    font-size: 13px;
    font-weight: 650;
    text-align: center;
    pointer-events: none;
  }
  .settings-card, .estimate-card, .rings-panel, .comparison-panel { padding: 14px; }
  .field input, .map-search-field input { font-size: 16px; }
  .radius-input input { font-size: 21px; }
}
@media (max-width: 365px) {
  .map-toolbar svg { display: none; }
}

.share-actions .button {
  width: 100%;
  height: 44px;
  min-width: 0;
  padding: 0 6px;
  justify-content: center;
  background: white;
}
.comparison-panel { margin: 0; }
#comparison-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
#comparison-guide { margin: 8px 0 12px; font-size: 13px; line-height: 1.5; }
.comparison-area { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--line); }
.comparison-area strong { color: var(--accent); font-size: 13px; overflow-wrap: anywhere; }
.comparison-area b { font-size: 18px; font-variant-numeric: tabular-nums; }
.comparison-area small { color: var(--muted); overflow-wrap: anywhere; }
.saved-actions, .comparison-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.saved-actions :is(a,button) { border: 0; background: none; padding: 6px 2px; font: inherit; font-size: 12px; color: var(--accent); text-decoration: underline; cursor: pointer; }
#compare-status:empty { display: none; }
#rings-table :is(td,th):last-child { text-align: right; padding-right: 0; }

/* The map and its inspector share one workspace. */
.site-shell { width: 100%; }
.site-header {
  display: grid;
  grid-template-columns: auto minmax(180px, 440px) 1fr;
  gap: clamp(18px, 4vw, 64px);
  padding: 9px clamp(14px, 2vw, 32px);
  background: #172037;
  color: white;
  min-height: 60px;
}
.site-header nav { justify-self: end; grid-column: -2; }
.site-header :is(.brand, nav a) { color: white; }
.site-header nav a:hover { background: #303b53; }
.brand-mark { color: #182144; background: #c7d3ff; border-radius: 50%; }
.site-header .map-search-bar { position: relative; inset: auto; width: 100%; color: var(--ink); }
.map-search-field { height: 42px; border-color: transparent; border-radius: 24px; box-shadow: none; padding-inline: 15px; }
.app-main { padding: 0; }
.workspace {
  grid-template-columns: clamp(300px, 26vw, 400px) minmax(0, 1fr);
  grid-template-areas: "inspector map";
  gap: 0;
  background: white;
}
.panel { grid-area: inspector; gap: 0; border-right: 1px solid var(--line); }
.panel > * { padding: 19px clamp(16px, 1.65vw, 28px); border: 0; border-radius: 0; box-shadow: none; margin: 0; }
.panel > * + * { border-top: 1px solid var(--line); }
.page-heading h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(30px, 2.7vw, 43px); letter-spacing: -.045em; }
.page-heading p { font-size: 14px; margin-top: 6px; }
.map-panel { grid-area: map; position: sticky; top: 0; border: 0; border-radius: 0; box-shadow: none; }
#map { height: calc(100svh - 122px); min-height: 370px; }
.map-toolbar {
  position: absolute; z-index: 900; left: 16px; top: 14px;
  padding: 4px; border: 1px solid #c4ccdc; border-radius: 13px;
  background: white; box-shadow: 0 4px 18px #17203724; gap: 4px;
}
.shape-switch { background: transparent; padding: 0; }
.shape-switch button[aria-pressed="true"] { background: var(--ink); color: white; }
.map-tools { border-left: 1px solid var(--line); padding-left: 4px; }
.map-caption { background: #f8f9fc; padding-inline: 18px; }
.estimate-card { background: #f0f3ff; }
.number { color: #233680; font-family: Georgia, serif; font-weight: 500; letter-spacing: -.045em; font-size: clamp(37px, 3.4vw, 54px); }
.shape-measures div { background: #ffffffba; }
.panel-source { border-color: #d2d9ef; }
.comparison-area { padding: 12px; margin-block: 8px; border: 1px solid var(--line); border-radius: 12px; }
.about-estimates, .site-footer, .article { padding-inline: clamp(18px, 3vw, 48px); }
.about-estimates { padding-block: 22px; border-top: 1px solid var(--line); }
.article { margin-inline: auto; }
@media (max-width: 760px) {
  .site-header { grid-template-columns: 1fr auto; gap: 10px; padding: 10px 14px; }
  .site-header nav { grid-column: 2; grid-row: 1; }
  .site-header .map-search-bar { grid-row: 2; grid-column: 1 / -1; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "map" "inspector"; }
  .map-panel { position: relative; }
  .map-toolbar { left: 8px; top: 8px; max-width: calc(100% - 55px); }
  #map { height: clamp(265px, 46svh, 450px); min-height: 0; }
  .map-caption { min-height: 42px; padding-inline: 10px; }
  .panel { border-right: 0; }
  .panel > * { padding: 16px; }
  .mobile-result:not(:empty) { pointer-events: auto; text-decoration: none; background: #172037; color: white; border-radius: 20px; }
  .mobile-result:not(:empty)::after { content: " ↓"; }
}

.map-toolbar {
  position: relative;
  inset: auto;
  max-width: none;
  justify-content: flex-start;
  padding: 6px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}
.analysis-tools {
  display: flex;
  margin-left: auto;
  padding: 2px;
  gap: 2px;
  border-radius: 9px;
  background: #f0f2f8;
}
.analysis-tools button[aria-expanded="true"] { color: white; background: var(--accent); }
.analysis-panels { position: relative; z-index: 800; }
.analysis-panels > section {
  position: absolute;
  top: 6px;
  right: 10px;
  width: min(350px, calc(100% - 20px));
  max-height: min(60svh, 520px);
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 6px 24px #17203724;
}
#map { height: calc(100svh - 176px); }
.map-stage { isolation: isolate; }
@media (max-width: 760px) {
  .map-toolbar { padding: 4px 6px; }
  .analysis-tools .button { padding-inline: 9px; }
  .analysis-panels > section {
    position: static;
    width: 100%;
    max-height: 32svh;
    border: 0;
    border-radius: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: none;
  }
  #map { height: clamp(265px, 46svh, 450px); }
}
