:root {
  --bg: #f3eadf;
  --paper: rgba(255, 250, 242, 0.82);
  --paper-strong: rgba(255, 252, 247, 0.94);
  --ink: #15202a;
  --muted: #5d6a71;
  --accent: #ff6a3d;
  --accent-dark: #d74b21;
  --line: rgba(21, 32, 42, 0.08);
  --shadow: 0 22px 70px rgba(80, 56, 25, 0.16);
  --mkad-fill: rgba(255, 106, 61, 0.16);
  --mkad-stroke: #ff6a3d;
  --route: #1565c0;
  --danger: #c8442d;
  --danger-bg: rgba(200, 68, 45, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  -webkit-touch-callout: none;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 24%),
    linear-gradient(135deg, #faf6ef 0%, #efe4d3 48%, #e7d8c3 100%);
  transition: background 0.45s ease, color 0.35s ease;
}

body.dark-mode {
  --bg: #0d141b;
  --paper: rgba(19, 28, 38, 0.82);
  --paper-strong: rgba(22, 32, 43, 0.96);
  --ink: #edf4fb;
  --muted: #9fb0c1;
  --accent: #ff7a45;
  --accent-dark: #d95829;
  --line: rgba(236, 244, 251, 0.1);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  --mkad-fill: rgba(255, 122, 69, 0.2);
  --mkad-stroke: #ff7a45;
  --route: #67b6ff;
  --danger: #ff8a66;
  --danger-bg: rgba(255, 138, 102, 0.18);
  background:
    radial-gradient(circle at top left, rgba(82, 124, 163, 0.18), transparent 22%),
    radial-gradient(circle at top right, rgba(255, 122, 69, 0.1), transparent 24%),
    linear-gradient(135deg, #081018 0%, #111b25 45%, #172330 100%);
}

.page {
  width: min(1360px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 20px 0 30px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 18px;
  margin-bottom: 18px;
}

.hero__copy,
.hero__meta,
.panel,
.map-card,
.result-card {
  background: var(--paper);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease, color 0.35s ease, filter 0.45s ease;
}

body.dark-mode .hero__copy,
body.dark-mode .hero__meta,
body.dark-mode .panel,
body.dark-mode .map-card,
body.dark-mode .result-card {
  border-color: rgba(255, 255, 255, 0.08);
}

.hero__copy {
  border-radius: 30px;
  padding: 22px 24px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

h1 {
  margin: 0;
  max-width: none;
  font-size: clamp(20px, 2.25vw, 30px);
  line-height: 1.02;
}

.lead {
  margin: 14px 0 0;
  max-width: 54ch;
  color: var(--muted);
  line-height: 1.5;
  font-size: 15px;
}

.hero__meta {
  border-radius: 30px;
  padding: 18px;
  display: grid;
  gap: 12px;
}

.meta-card,
.result-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  transition: background-color 0.35s ease, border-color 0.35s ease, color 0.35s ease, filter 0.45s ease;
}

body.dark-mode .meta-card,
body.dark-mode .result-card {
  background: rgba(255, 255, 255, 0.04);
}

.meta-card__label,
.result-card__label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel,
.map-card {
  border-radius: 30px;
}

.panel {
  padding: 22px;
}

.panel__header h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.panel__header p {
  margin: 0 0 18px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field[hidden] {
  display: none;
}

.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  transition: background-color 0.35s ease, border-color 0.35s ease, color 0.35s ease;
}

body.dark-mode .switch-field {
  background: rgba(255, 255, 255, 0.04);
}

.switch-field__label {
  font-weight: 600;
  color: var(--ink);
}

.switch {
  position: relative;
  width: 58px;
  height: 32px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(21, 32, 42, 0.16);
  transition: background 0.2s ease;
}

body.dark-mode .switch__track {
  background: rgba(236, 244, 251, 0.18);
}

.switch__thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, background 0.2s ease;
}

.switch input:checked ~ .switch__track {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.switch input:checked ~ .switch__thumb {
  transform: translateX(26px);
}

.switch input:focus-visible ~ .switch__track {
  outline: 2px solid rgba(103, 182, 255, 0.65);
  outline-offset: 2px;
}

.field span {
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(21, 32, 42, 0.12);
  background: var(--paper-strong);
  color: var(--ink);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  transition: background-color 0.35s ease, border-color 0.35s ease, color 0.35s ease;
}

body.dark-mode .field input,
body.dark-mode .field select {
  border-color: rgba(236, 244, 251, 0.1);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.3s ease, background 0.35s ease, color 0.35s ease;
  will-change: transform;
}

.button:hover,
.toast__action:hover,
.toast__close:hover,
.theme-toggle:hover {
  filter: brightness(1.04);
}

.button:active,
.toast__action:active,
.toast__close:active,
.theme-toggle:active {
  animation: press-bounce 0.28s ease;
}

.button:focus-visible,
.toast__action:focus-visible,
.toast__close:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid rgba(103, 182, 255, 0.65);
  outline-offset: 2px;
}

.button--ghost {
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  border: 1px solid var(--line);
}

body.dark-mode .button--ghost {
  background: rgba(255, 255, 255, 0.06);
}

.hint {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  line-height: 1.5;
  transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease;
}

body.dark-mode .hint {
  background: rgba(255, 255, 255, 0.04);
}

.map-card {
  padding: 14px;
}

.map-card__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 4px 14px;
}

.map-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 4px 4px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: white;
  background: var(--accent);
}

.tag--soft {
  background: rgba(21, 101, 192, 0.12);
  color: #1565c0;
}

.tag--exit {
  background: rgba(255, 106, 61, 0.16);
  color: #b4431d;
}

body.dark-mode .tag--soft {
  background: rgba(103, 182, 255, 0.12);
  color: #67b6ff;
}

body.dark-mode .tag--exit {
  background: rgba(255, 122, 69, 0.18);
  color: #ffb090;
}

#map {
  width: 100%;
  height: min(72vh, 760px);
  border-radius: 24px;
  overflow: hidden;
  background: #dce7ea;
}

body.dark-mode #map {
  background: #0e1720;
}

.results {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.coord-link {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

body.dark-mode .coord-link {
  color: #ffb090;
}

.ymaps-2-1-79-map,
.ymaps-2-1-79-inner-panes,
.ymaps-2-1-79-ground-pane {
  border-radius: 24px;
}

body.dark-mode .ymaps-2-1-79-ground-pane,
body.dark-mode .ymaps-2-1-79-copyright,
body.dark-mode .ymaps-2-1-79-map-copyrights-promo,
body.dark-mode .ymaps-2-1-79-controls-pane {
  filter: invert(1) hue-rotate(180deg) saturate(0.7) brightness(0.82) contrast(1.05);
  transition: filter 0.45s ease, opacity 0.35s ease;
}

.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-strong);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 2000;
  backdrop-filter: blur(18px);
  transition: background-color 0.35s ease, border-color 0.35s ease, color 0.35s ease, box-shadow 0.35s ease, transform 0.25s ease, filter 0.35s ease;
}

.theme-toggle__icon {
  font-size: 22px;
  line-height: 1;
  color: #ffd66e;
  transition: color 0.35s ease, transform 0.35s ease, opacity 0.35s ease;
}

body.dark-mode .theme-toggle__icon {
  color: #9db1c6;
  transform: rotate(-14deg) scale(0.96);
}

.toast {
  position: fixed;
  top: 82px;
  right: 18px;
  max-width: min(420px, calc(100vw - 36px));
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--paper-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  z-index: 2100;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast[hidden] {
  display: none !important;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast--copy {
  top: auto;
  bottom: 18px;
  transform: translateY(10px);
}

.toast--copy.is-visible {
  transform: translateY(0);
}

.toast--error {
  background: color-mix(in srgb, var(--paper-strong) 82%, var(--danger-bg));
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.toast--error .toast__title {
  color: var(--danger);
}

.toast--error .toast__close {
  color: var(--danger);
}

.toast--loading {
  top: 82px;
  right: 18px;
  align-items: center;
  padding-right: 20px;
}

.toast__spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(21, 32, 42, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  flex: 0 0 auto;
  animation: spin 0.9s linear infinite;
}

body.dark-mode .toast__spinner {
  border-color: rgba(236, 244, 251, 0.14);
  border-top-color: var(--accent);
}

.toast__content {
  display: grid;
  gap: 6px;
}

.toast__title {
  font-size: 14px;
}

.toast__text {
  color: var(--muted);
  line-height: 1.45;
}

.toast__action {
  justify-self: start;
  margin-top: 4px;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.25s ease, background 0.35s ease;
}

.toast__close {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.25s ease, color 0.25s ease;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes press-bounce {
  0% {
    transform: scale(1);
  }

  45% {
    transform: scale(0.94);
  }

  100% {
    transform: scale(1.02);
  }
}

@media (max-width: 1080px) {
  .hero,
  .workspace,
  .results {
    grid-template-columns: 1fr;
  }

  .page {
    width: min(100vw - 18px, 1360px);
    padding-top: 10px;
  }

  h1 {
    max-width: none;
    font-size: clamp(22px, 8vw, 34px);
  }

  #map {
    height: 60vh;
  }
}

@media (max-width: 820px) {
  .page {
    width: min(100vw - 16px, 1360px);
    padding: 12px 0 22px;
  }

  .hero {
    gap: 12px;
    margin-bottom: 12px;
  }

  .hero__copy,
  .hero__meta,
  .panel,
  .map-card,
  .result-card {
    border-radius: 24px;
  }

  .hero__copy,
  .panel {
    padding: 18px;
  }

  .hero__meta,
  .map-card {
    padding: 14px;
  }

  .lead,
  .panel__header p,
  .hint {
    font-size: 14px;
  }

  .workspace {
    gap: 12px;
  }

  .results {
    gap: 12px;
    margin-top: 12px;
  }

  .actions,
  .map-card__actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .switch-field {
    align-items: flex-start;
  }

  .switch {
    margin-top: 2px;
  }

  .theme-toggle {
    top: 12px;
    right: 12px;
    width: 46px;
    height: 46px;
  }

  .theme-toggle__icon {
    font-size: 20px;
  }

  .toast,
  .toast--loading {
    top: auto;
    right: 12px;
    left: 12px;
    max-width: none;
  }

  .toast {
    bottom: 12px;
    transform: translateY(10px);
  }

  .toast.is-visible {
    transform: translateY(0);
  }

  .toast--loading {
    bottom: 12px;
    padding-right: 16px;
  }

  #map {
    height: 52vh;
    min-height: 340px;
    border-radius: 20px;
  }

  .ymaps-2-1-79-map,
  .ymaps-2-1-79-inner-panes,
  .ymaps-2-1-79-ground-pane {
    border-radius: 20px;
  }
}

@media (max-width: 560px) {
  .page {
    width: calc(100vw - 12px);
    padding-top: 10px;
  }

  .hero__copy,
  .panel {
    padding: 16px;
  }

  .hero__meta,
  .map-card,
  .result-card {
    padding: 12px;
  }

  .eyebrow,
  .meta-card__label,
  .result-card__label {
    font-size: 11px;
    letter-spacing: 0.12em;
  }

  h1 {
    font-size: 22px;
    line-height: 1.08;
  }

  .lead {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.4;
  }

  .panel__header h2 {
    font-size: 20px;
  }

  .field input,
  .field select {
    padding: 13px 14px;
    border-radius: 14px;
    font-size: 16px;
  }

  .switch-field {
    padding: 12px 14px;
    border-radius: 16px;
  }

  .switch-field__label {
    max-width: 210px;
    font-size: 14px;
    line-height: 1.3;
  }

  .map-card__toolbar {
    gap: 8px;
    padding-bottom: 10px;
  }

  .tag {
    padding: 7px 10px;
    font-size: 11px;
  }

  #map {
    height: 46vh;
    min-height: 300px;
    border-radius: 18px;
  }

  .ymaps-2-1-79-map,
  .ymaps-2-1-79-inner-panes,
  .ymaps-2-1-79-ground-pane {
    border-radius: 18px;
  }

  .result-card strong,
  #mkad-point-value {
    font-size: 14px;
    line-height: 1.35;
    word-break: break-word;
  }

  .toast,
  .toast--loading {
    left: 8px;
    right: 8px;
    bottom: 8px;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 16px;
  }

  .toast__title {
    font-size: 13px;
  }

  .toast__text {
    font-size: 13px;
  }

  .toast__action {
    width: 100%;
    justify-self: stretch;
    text-align: center;
  }

  .toast__close {
    font-size: 22px;
  }
}
