/* ── Coordinate Distance Calculator ── */
:root {
  --bg: #0f0f14;
  --bg-card: #1e1e28;
  --bg-surface: #18181f;
  --primary: #3b82f6;
  --secondary: #2563eb;
  --accent: #60a5fa;
  --teal: #2dd4bf;
  --orange: #f97316;
  --purple: #a78bfa;
  --green: #22c55e;
  --yellow: #eab308;
  --text: #e8e8f0;
  --text-muted: #9999b8;
  --text-faint: #555570;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased
}

a {
  color: var(--primary);
  text-decoration: none
}

a:hover {
  text-decoration: underline
}

code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: rgba(59, 130, 246, .1);
  color: #93c5fd;
  padding: 2px 6px;
  border-radius: 4px
}

/* ── HEADER ── */
.site-header {
  background: rgba(15, 15, 20, .9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center
}

.header-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none
}

.logo-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0
}

.logo-text {
  font-size: .97rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em
}

.main-nav {
  display: flex;
  gap: 6px
}

.nav-link {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s, background .15s
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: rgba(255, 255, 255, .06)
}

/* ── LAYOUT ── */
.main-wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 28px 24px 80px
}

@media(max-width:640px) {
  .main-wrap {
    padding: 18px 14px 60px
  }
}

/* ── HERO ── */
.tool-hero {
  text-align: center;
  padding: 24px 0 20px
}

.tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  background: rgba(59, 130, 246, .1);
  color: var(--accent);
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 600;
  margin-bottom: 12px
}

.tool-title {
  font-size: clamp(1.7rem, 4.5vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -.03em;
  margin-bottom: 8px;
  line-height: 1.1
}

.gradient-title {
  background: linear-gradient(135deg, var(--accent), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text
}

.tool-subtitle {
  font-size: .97rem;
  color: var(--text-muted);
  max-width: 580px;
  margin: 0 auto
}

/* ── AD ── */
.ad-slot {
  background: rgba(255, 255, 255, .02);
  border: 1px dashed rgba(255, 255, 255, .07);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  font-size: .75rem;
  color: var(--text-faint);
  text-align: center;
  padding: 12px;
  margin-bottom: 20px
}

/* ── CARD ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px
}

.card-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .02);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap
}

.card-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0
}

.card-icon svg {
  width: 14px;
  height: 14px
}

.card-icon.blue {
  background: rgba(59, 130, 246, .12);
  color: var(--primary)
}

.card-icon.teal {
  background: rgba(45, 212, 191, .12);
  color: var(--teal)
}

.card-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint)
}

.card-body {
  padding: 20px
}

/* ── POINT GRID ── */
.points-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px
}

@media(max-width:640px) {
  .points-grid {
    grid-template-columns: 1fr
  }
}

.point-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px
}

.point-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px
}

.point-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 800;
  flex-shrink: 0
}

.dot-a {
  background: rgba(59, 130, 246, .2);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, .35)
}

.dot-b {
  background: rgba(45, 212, 191, .2);
  color: var(--teal);
  border: 1px solid rgba(45, 212, 191, .35)
}

.point-name {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text)
}

.point-optional {
  font-size: .72rem;
  color: var(--text-faint);
  margin-left: auto
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px
}

.field-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px
}

.field-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint)
}

.field-input {
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  color: var(--text);
  font-size: .88rem;
  font-family: var(--font-mono);
  width: 100%;
  outline: none;
  transition: border-color .15s
}

.field-input:focus {
  border-color: var(--primary)
}

.field-input::placeholder {
  color: var(--text-faint)
}

.field-input.err {
  border-color: rgba(239, 68, 68, .4)
}

.field-err {
  font-size: .7rem;
  color: #fca5a5;
  margin-top: 2px
}

.name-input {
  width: 100%;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  color: var(--text-muted);
  font-size: .82rem;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s;
  margin-bottom: 10px
}

.name-input:focus {
  border-color: rgba(255, 255, 255, .18)
}

/* ── SWAP BUTTON ── */
.swap-row {
  display: flex;
  justify-content: center;
  margin: 6px 0
}

.swap-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s
}

.swap-btn:hover {
  border-color: var(--primary);
  color: var(--accent);
  background: rgba(59, 130, 246, .07)
}

.swap-btn svg {
  width: 14px;
  height: 14px
}

/* ── FORMAT TABS ── */
.format-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap
}

.format-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-faint)
}

.fmt-chip {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 700;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: all .15s
}

.fmt-chip.active {
  background: rgba(59, 130, 246, .15);
  border-color: rgba(59, 130, 246, .4);
  color: var(--accent)
}

.fmt-chip:hover:not(.active) {
  border-color: rgba(255, 255, 255, .2);
  color: var(--text)
}

/* ── ACTION ROW ── */
.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--teal));
  color: #fff;
  font-weight: 700;
  font-size: .88rem;
  border: none;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap
}

.btn-primary:hover {
  opacity: .88
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, .2);
  color: var(--text)
}

.btn-primary svg,
.btn-secondary svg {
  width: 14px;
  height: 14px
}

/* ── RESULT CARD ── */
.result-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, .07), rgba(45, 212, 191, .07));
  border: 1px solid rgba(59, 130, 246, .25);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px
}

.result-main {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px
}

.result-distance {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1
}

.result-km {
  background: linear-gradient(135deg, var(--accent), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text
}

.result-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 6px
}

.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px
}

.unit-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px
}

.unit-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint)
}

.unit-value {
  font-size: .97rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text)
}

.bearing-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px
}

.bearing-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  flex: 1;
  min-width: 160px
}

.bearing-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  margin-bottom: 3px
}

.bearing-value {
  font-size: .95rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text)
}

.bearing-compass {
  font-size: .8rem;
  color: var(--accent);
  margin-left: 6px
}

.midpoint-row {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap
}

.midpoint-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  flex-shrink: 0
}

.midpoint-val {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text-muted)
}

.copy-tiny {
  padding: 3px 9px;
  border-radius: 6px;
  font-size: .7rem;
  font-weight: 700;
  border: 1px solid var(--border);
  color: var(--text-faint);
  cursor: pointer;
  background: transparent;
  transition: all .15s;
  margin-left: auto;
  flex-shrink: 0
}

.copy-tiny:hover {
  border-color: var(--primary);
  color: var(--accent)
}

/* ── MULTI POINT MODE ── */
.multi-list {
  display: flex;
  flex-direction: column;
  gap: 8px
}

.multi-item {
  display: grid;
  grid-template-columns: 24px 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px
}

.multi-idx {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-faint);
  text-align: center
}

.multi-input {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .84rem;
  outline: none;
  width: 100%;
  padding: 2px 0
}

.multi-input::placeholder {
  color: var(--text-faint)
}

.multi-remove {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all .15s;
  flex-shrink: 0
}

.multi-remove:hover {
  border-color: rgba(239, 68, 68, .4);
  color: #f87171;
  background: rgba(239, 68, 68, .06)
}

.multi-leg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(59, 130, 246, .04);
  border: 1px solid rgba(59, 130, 246, .1);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  color: var(--text-muted)
}

.leg-label {
  font-weight: 600;
  color: var(--text-faint)
}

.leg-dist {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent)
}

.total-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(45, 212, 191, .05);
  border: 1px solid rgba(45, 212, 191, .2);
  border-radius: var(--radius-sm);
  font-size: .84rem;
  font-weight: 600;
  color: var(--teal);
  margin-top: 4px
}

/* ── SECTIONS ── */
.page-section {
  margin-top: clamp(28px, 4vw, 48px)
}

.section-head {
  margin-bottom: 18px
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 5px
}

.section-desc {
  font-size: .86rem;
  color: var(--text-muted);
  line-height: 1.7
}

.section-divider {
  height: 1px;
  background: var(--border);
  margin: clamp(28px, 4vw, 48px) 0
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px
}

.feature-icon {
  font-size: 1.4rem;
  margin-bottom: 10px
}

.feature-title {
  font-size: .88rem;
  font-weight: 700;
  margin-bottom: 5px
}

.feature-desc {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.6
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px
}

.step-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 10px
}

.step-title {
  font-size: .87rem;
  font-weight: 700;
  margin-bottom: 5px
}

.step-desc {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.6
}

/* ── FAQ ── */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden
}

.faq-q {
  width: 100%;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: background .15s
}

.faq-q:hover {
  background: rgba(255, 255, 255, .025)
}

.faq-icon {
  font-size: .9rem;
  color: var(--text-faint);
  transition: transform .25s;
  flex-shrink: 0
}

.faq-item.open .faq-icon {
  transform: rotate(45deg);
  color: var(--primary)
}

.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease, padding .25s ease
}

.faq-item.open .faq-a {
  max-height: 400px;
  padding: 0 16px 14px
}

.faq-a p {
  font-size: .86rem;
  color: var(--text-muted);
  line-height: 1.78
}

.faq-a code {
  font-size: .82em
}

/* ── RELATED ── */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px
}

.related-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: all .15s
}

.related-card:hover {
  border-color: rgba(59, 130, 246, .3);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3)
}

.related-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center
}

.related-icon svg {
  width: 16px;
  height: 16px;
  color: #fff
}

.related-name {
  font-size: .86rem;
  font-weight: 700
}

.related-desc {
  font-size: .77rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1
}

.related-link {
  font-size: .77rem;
  font-weight: 600;
  color: var(--primary)
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid rgba(59, 130, 246, .4);
  border-radius: var(--radius-sm);
  font-size: .84rem;
  font-weight: 600;
  color: var(--accent);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .4);
  opacity: 0;
  transform: translateY(8px);
  transition: all .22s;
  pointer-events: none;
  z-index: 999
}

.toast.show {
  opacity: 1;
  transform: translateY(0)
}

/* ── FOOTER ── */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: clamp(24px, 4vw, 44px) 0 18px
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 36px;
  margin-bottom: 32px;
  width: 100%;
  max-width: 1060px;
  margin-inline: auto;
  padding-inline: 24px
}

.footer-brand-text {
  font-size: .86rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-top: 9px;
  max-width: 230px
}

.footer-heading {
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  margin-bottom: 10px
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 7px
}

.footer-links a {
  font-size: .86rem;
  color: var(--text-muted)
}

.footer-links a:hover {
  color: var(--text)
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
  font-size: .8rem;
  color: var(--text-faint);
  width: 100%;
  max-width: 1060px;
  margin-inline: auto;
  padding-inline: 24px
}

.tab {
  padding: 10px 20px;
  background-color: #e0e0e0;
  border: 1px solid #ccc;
  border-bottom: none;
  cursor: pointer;
  font-weight: 600;
  color: #333;
  border-radius: 4px 4px 0 0;
  margin-right: 4px;
  user-select: none;
  transition: background-color 0.2s ease;
}

@media(max-width:640px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr
  }

  .points-grid {
    grid-template-columns: 1fr
  }

  .units-grid {
    grid-template-columns: 1fr 1fr
  }
}