:root {
  --bg: #ffffff;
  --surface: #f3f4f6;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --a: #16a34a;
  --b: #dc2626;
  --error: #dc2626;
  --shadow: 0 -8px 24px rgba(17, 24, 39, 0.10);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181c;
    --surface: #24262c;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --line: #33363d;
    --accent: #3b82f6;
    --shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Карта */

.map-wrap {
  position: relative;
  flex: 0 0 44dvh;
  min-height: 240px;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--surface);
}

.picker {
  position: absolute;
  z-index: 500;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
}

.picker-label {
  padding: 0 6px 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.picker button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.picker button.active {
  background: var(--surface);
  font-weight: 600;
}

.dot {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font: 700 12px/1 inherit;
  font-style: normal;
}

.dot-a { background: var(--a); }
.dot-b { background: var(--b); }

.pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  color: #fff;
  font: 700 14px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.pin span { transform: rotate(45deg); }
.pin-a { background: var(--a); }
.pin-b { background: var(--b); }

/* Карточка снизу */

.sheet {
  position: relative;
  z-index: 600;
  flex: 1 0 auto;
  margin-top: -18px;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--bg);
  box-shadow: var(--shadow);
}

h1 {
  margin: 0 0 14px;
  font-size: 20px;
  line-height: 1.25;
}

.route {
  border-radius: 14px;
  background: var(--surface);
}

.field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 12px;
}

.field + .field { border-top: 1px solid var(--line); }

.field input {
  flex: 1;
  min-width: 0;
  height: 52px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
}

.field input::placeholder { color: var(--muted); }

.clear {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.suggest {
  position: absolute;
  z-index: 10;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 4px 0;
  list-style: none;
  border-radius: 14px;
  background: var(--bg);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  max-height: 260px;
  overflow-y: auto;
}

.suggest li {
  padding: 11px 14px;
  font-size: 15px;
  cursor: pointer;
}

.suggest li + li { border-top: 1px solid var(--line); }
.suggest li:active, .suggest li:hover { background: var(--surface); }
.suggest li.note { color: var(--muted); cursor: default; background: none; }

.hint {
  margin: 10px 2px 0;
  font-size: 14px;
  color: var(--muted);
}

/* Цена */

.quote {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  animation: rise 0.25s ease-out;
}

.quote { display: block; padding: 12px; }

.quote-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 0 4px 10px;
}

.quote-label { font-size: 14px; font-weight: 600; }
.meta { font-size: 13px; color: var(--muted); text-align: right; }

.tariffs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tariff {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 10px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tariff b { font-size: 14px; }
.tariff span { font-size: 12px; color: var(--muted); }
.tariff strong { margin-top: 6px; font-size: 17px; font-weight: 800; white-space: nowrap; }
.tariff.active { border-color: var(--accent); }

.quote.loading .tariffs { opacity: 0.35; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Форма */

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

form input, form textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
  resize: none;
}

form input:focus, form textarea:focus { border-color: var(--accent); }
form .invalid { border-color: var(--error); }

.primary {
  height: 54px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary:disabled { opacity: 0.6; }

.error {
  margin: 0;
  font-size: 14px;
  color: var(--error);
}

/* Заявка отправлена */

.done { text-align: center; }

.check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 6px auto 14px;
  border-radius: 50%;
  background: var(--a);
  color: #fff;
  font-size: 34px;
  font-weight: 700;
}

.done-text { margin: 0 0 16px; color: var(--muted); }

.done-route {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  font-size: 15px;
}

.done-route div + div { margin-top: 8px; }
.done-route b { font-weight: 600; }
.done .primary { width: 100%; }

[hidden] { display: none !important; }
