:root {
  color-scheme: dark;
  --ink: #f6f3eb;
  --muted: #a8ada4;
  --panel: #111714;
  --panel-soft: #19211d;
  --line: #303a34;
  --lime: #c8f04c;
  --lime-deep: #9dca20;
  --coral: #ff775f;
  --cyan: #55d8d0;
  --danger: #ff8b78;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  background: #0b0f0d;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 430px) 1fr;
  width: 100%;
  height: 100%;
  min-height: 720px;
}

.control-panel {
  position: relative;
  z-index: 2;
  overflow-y: auto;
  padding: 30px 30px 36px;
  background:
    radial-gradient(circle at 90% 0%, rgb(200 240 76 / 10%), transparent 32%),
    var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 18px 0 48px rgb(0 0 0 / 24%);
}

.brand {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: block;
  margin-bottom: 10px;
  color: var(--lime);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 360px;
  margin-bottom: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 4vw, 52px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.035em;
}

.brand p {
  max-width: 350px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.server-state {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 26px;
  padding: 13px 14px;
  background: rgb(255 255 255 / 3%);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.server-state div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.server-state strong {
  font-size: 13px;
}

.server-state span:last-child {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  background: #e8b34d;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgb(232 179 77 / 13%);
}

.status-dot.ready {
  background: var(--lime);
  box-shadow: 0 0 0 4px rgb(200 240 76 / 13%);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgb(255 139 120 / 13%);
}

.point-section,
.limits-section {
  margin-bottom: 26px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h2 {
  margin-bottom: 13px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.text-button {
  padding: 4px 0;
  color: var(--lime);
  background: transparent;
  border: 0;
  font-size: 12px;
}

.point-card {
  margin: 0 0 10px;
  padding: 10px 14px 13px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.point-card legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.point-card legend span {
  display: inline-grid;
  width: 22px;
  height: 22px;
  margin-right: 5px;
  place-items: center;
  color: #0c100e;
  border-radius: 50%;
}

.start-card legend span {
  background: var(--lime);
}

.finish-card legend span {
  background: var(--coral);
}

.coordinate-grid,
.parameter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  color: var(--ink);
  background: #0d1210;
  border: 1px solid #364139;
  border-radius: 8px;
  outline: none;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-transform: none;
}

input:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgb(200 240 76 / 10%);
}

input[readonly] {
  color: var(--muted);
}

.point-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 10px;
}

.point-card small.snapped {
  color: var(--lime);
}

.selection-hint {
  padding: 5px 3px 0;
  color: var(--muted);
  font-size: 11px;
}

.selection-hint strong {
  color: var(--ink);
}

.actions {
  display: grid;
  gap: 9px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.primary-button {
  color: #11150f;
  background: var(--lime);
  border: 1px solid var(--lime);
}

.primary-button:hover {
  background: #d5fa62;
}

.secondary-button {
  color: var(--ink);
  background: transparent;
  border: 1px solid #3c4841;
}

.secondary-button:hover {
  border-color: #65736a;
}

.result-card {
  min-height: 112px;
  margin-top: 18px;
  padding: 16px;
  background: #0b100e;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.result-placeholder span,
.result-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.result-placeholder p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.metric {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.metric strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 500;
}

.metric span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.snap-summary {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.diagnostics-title {
  margin-top: 17px;
  padding-top: 14px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.diagnostics-grid div {
  min-width: 0;
  padding: 9px 10px;
  background: rgb(255 255 255 / 3%);
  border: 1px solid rgb(255 255 255 / 5%);
  border-radius: 8px;
}

.diagnostics-grid strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diagnostics-grid span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.25;
  text-transform: uppercase;
}

.timing-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.result-error {
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.map-region {
  position: relative;
  min-width: 0;
  min-height: 560px;
}

#map {
  width: 100%;
  height: 100%;
  background: #d8d7cc;
}

.map-instruction,
.map-control,
.map-legend {
  position: absolute;
  z-index: 500;
  color: #172018;
  background: rgb(246 243 235 / 94%);
  border: 1px solid rgb(17 23 20 / 14%);
  box-shadow: 0 8px 30px rgb(0 0 0 / 14%);
  backdrop-filter: blur(8px);
}

.map-instruction {
  top: 18px;
  left: 50%;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  transform: translateX(-50%);
}

.map-control {
  top: 18px;
  right: 18px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
}

.map-legend {
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 14px;
  padding: 10px 13px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
}

.map-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.legend-dot.start {
  background: var(--lime-deep);
}

.legend-dot.finish {
  background: var(--coral);
}

.legend-line {
  width: 17px;
  height: 3px;
  background: #27685f;
  border-radius: 5px;
}

.route-marker {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #11150f;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 3px 12px rgb(0 0 0 / 35%);
  font-size: 12px;
  font-weight: 900;
}

.route-marker.start {
  background: var(--lime);
}

.route-marker.finish {
  background: var(--coral);
}

.snap-marker {
  width: 12px;
  height: 12px;
  background: var(--cyan);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgb(0 0 0 / 32%);
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 62vh);
    height: auto;
  }

  .control-panel {
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-region {
    min-height: 520px;
  }
}

@media (max-width: 520px) {
  .control-panel {
    padding: 24px 18px 28px;
  }

  .coordinate-grid,
  .parameter-grid {
    grid-template-columns: 1fr;
  }

  .map-instruction {
    display: none;
  }

  .map-control {
    top: 12px;
    right: 12px;
  }

  .map-legend {
    right: 12px;
    bottom: 12px;
    left: 12px;
    justify-content: center;
  }
}
