:root {
  --ink: #0f172a;
  --muted: #475569;
  --line: #cbd5e1;
  --paper: #f8fafc;
  --card: #ffffff;
  --brand: #1d4ed8;
  --brand-dark: #1e40af;
  --brand-soft: #eff6ff;
  --warn-bg: #fffbeb;
  --warn-line: #f59e0b;
  --error: #b91c1c;
  --ok: #166534;
  --radius: 14px;
  --focus: 3px solid #1d4ed8;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
canvas:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  z-index: 50;
}
.skip-link:focus { left: 8px; top: 8px; }

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
}
.site-nav { display: flex; gap: 18px; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.site-nav a:hover { color: var(--brand); text-decoration: underline; }

.wrap {
  width: min(1060px, 100% - 40px);
  margin-inline: auto;
}
main { display: block; }
.hero { padding: 44px 0 8px; }
.hero .lede {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 60ch;
  margin: 8px 0 0;
}
h1 {
  font-size: clamp(2rem, 4.2vw, 2.85rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}
h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.65rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
h3 { font-size: 1.05rem; margin: 0 0 6px; }
p { margin: 0 0 14px; }

.section { padding: 26px 0; }
.section-head { margin-bottom: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%), 0 12px 32px -18px rgb(15 23 42 / 18%);
}

.finder { padding: 22px; }
.finder .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  min-height: 46px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { border-color: #94a3b8; background: #f8fafc; }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.status {
  min-height: 24px;
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 10px;
}
.status[data-tone="error"] { color: var(--error); }
.status[data-tone="busy"] { color: var(--brand-dark); }

.panel { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 6px; }
.panel[hidden] { display: none; }

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 0.95rem; }
.field .hint { color: var(--muted); font-size: 0.85rem; }
.field input {
  font: inherit;
  padding: 11px 12px;
  border: 1px solid #94a3b8;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  min-height: 46px;
  width: 100%;
}
.field input[aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }
.field-error { color: var(--error); font-size: 0.88rem; min-height: 20px; margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.coords-hint { color: var(--muted); font-size: 0.9rem; margin: 6px 0 0; }

.map-panel { padding: 0; }
.map-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #eef2f7;
}
#map {
  display: block;
  width: 100%;
  height: 380px;
  touch-action: none;
  cursor: crosshair;
  background: #eef2f7;
}
.map-tools {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-tools .btn {
  min-height: 38px;
  width: 38px;
  padding: 0;
  justify-content: center;
  font-size: 1.1rem;
  background: rgb(255 255 255 / 95%);
  box-shadow: 0 1px 3px rgb(15 23 42 / 20%);
}
.map-help { color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }
.map-attrib {
  position: absolute;
  left: 8px;
  bottom: 6px;
  font-size: 0.7rem;
  color: #334155;
  background: rgb(255 255 255 / 82%);
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

.result {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  padding: 18px;
}
.result:empty { display: none; }
.result h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 6px; }
.result-name { font-size: 1.45rem; font-weight: 700; line-height: 1.25; margin: 0 0 6px; }
.result-meta { color: var(--muted); margin: 0 0 4px; font-size: 0.95rem; }
.result-point { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; margin: 0; }
.result-possible { margin: 10px 0 0; }
.result-list { margin: 8px 0 0; padding-left: 20px; }
.result-list li { margin-bottom: 2px; }

.near-note {
  margin-top: 12px;
  background: var(--warn-bg);
  border: 1px solid #fcd34d;
  border-left: 4px solid var(--warn-line);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.94rem;
}
.near-note[hidden] { display: none; }
.near-note p { margin: 0; }

.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.result-actions .btn { min-height: 42px; padding: 9px 14px; }
.result-actions [hidden] { display: none; }

.result.outside { background: #fff7ed; border-color: #fdba74; }
.result.line { background: #eff6ff; border-color: #93c5fd; }

.error-box {
  margin-top: 14px;
  border: 1px solid #fca5a5;
  background: #fef2f2;
  color: #7f1d1d;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.95rem;
}
.error-box[hidden] { display: none; }
.error-box p { margin: 0 0 8px; }
.error-box .btn { background: #fff; border-color: #fca5a5; color: #7f1d1d; min-height: 40px; padding: 8px 12px; }

.method-note {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}
.method-note p { margin: 0 0 6px; }

.source-line { color: var(--muted); font-size: 0.88rem; margin: 0; }
.source-line a { color: var(--brand); }

.prose { max-width: 72ch; }
.prose h2 { margin-top: 30px; }
.prose h2:first-child { margin-top: 0; }
.prose ul { padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.example-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 6px;
  font-size: 0.95rem;
}
.example-table th, .example-table td {
  text-align: left;
  border: 1px solid var(--line);
  padding: 9px 12px;
  vertical-align: top;
}
.example-table th { background: #f1f5f9; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.callout {
  background: var(--brand-soft);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 18px 0;
}
.callout p:last-child { margin-bottom: 0; }
.back-to-tool { margin-top: 20px; }
.data-note { font-size: 0.88rem; color: var(--muted); }

.site-footer {
  margin-top: 40px;
  border-top: 1px solid var(--line);
  padding: 24px 0 40px;
  color: var(--muted);
  font-size: 0.88rem;
}
.site-footer p { margin: 0 0 6px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .hero { padding-top: 28px; }
  .finder { padding: 16px; }
  .field-row { grid-template-columns: 1fr; }
  .btn { width: 100%; justify-content: center; }
  .map-tools .btn { width: 38px; }
  #map { height: 300px; }
  .site-nav { gap: 12px; }
  .result-name { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
