/* Токены дизайн-документа. / Design document tokens. */
:root {
  --paper: #f1f2f6;
  --surface: #fff;
  --ink: #16143c;
  --ink-soft: #6a6b86;
  --hairline: #dedfe8;
  --brand: #6c5ce7;
  --brand-press: #5546d6;
  --shadow: 0 12px 40px rgba(22, 20, 60, 0.14);
  --shadow-soft: 0 4px 18px rgba(22, 20, 60, 0.09);
  --r-pill: 999px;
  --r-panel: 28px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Onest, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  overscroll-behavior: none;
}
#map { position: fixed; inset: 0; }
.maplibregl-ctrl-attrib { border-radius: var(--r-pill) !important; font-size: 10px; }
.cluster { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font: 600 15px/1 Onest, sans-serif;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), background 0.18s, color 0.18s;
}
.pill:hover { transform: translateY(-1px); }
.pill:active { transform: scale(0.97); background: #f6f6fb; }
.pill:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.pill[aria-pressed="true"], .pill.is-on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-group .pill { height: 44px; padding: 0 16px; }
.controls { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.ask { display: flex; gap: 8px; }
.ask input {
  flex: 1; height: 44px; padding: 0 18px;
  border: 1px solid var(--hairline); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink);
  font: 500 14px/1 Onest, sans-serif; box-shadow: var(--shadow-soft);
}
.ask input::placeholder { color: #9a9ab4; }
.ask input:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.pill-go { width: 44px; padding: 0; justify-content: center; font-size: 18px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 8px 0 16px;
  border-radius: var(--r-pill); background: var(--surface);
  border: 1px dashed var(--brand); color: var(--ink);
  font: 600 13px/1 Onest, sans-serif; box-shadow: var(--shadow-soft);
}
.chip button {
  width: 24px; height: 24px; border: 0; border-radius: 50%;
  background: #efeefc; color: var(--brand); cursor: pointer; font-size: 14px; line-height: 1;
}
.chip-source { font: 500 12px/1 Onest, sans-serif; color: var(--ink-soft); }
.chip-apply { height: 38px; }
/* Шайбы: размер — часы на земле, кольцо — состояние окна ответа. */
.puck { display: grid; place-items: center; cursor: pointer; }
.puck-dot {
  border-radius: 50%;
  background: #c3c6d2;
  box-shadow: 0 6px 18px rgba(22, 20, 60, 0.22);
  transition: background 0.25s linear;
}
.puck-halo {
  position: absolute; border-radius: 50%; opacity: 0.22;
  background: inherit; pointer-events: none;
}
.puck-name {
  position: absolute; top: 100%; margin-top: 4px; white-space: nowrap;
  font: 600 12px/1 Onest, sans-serif; color: var(--ink);
  text-shadow: 0 1px 0 #fff, 0 0 6px #fff, 0 0 10px #fff;
  pointer-events: none;
}
.puck-ring {
  position: absolute; border-radius: 50%;
  border: 2px dashed var(--ink); opacity: 0.55; pointer-events: none;
}
.card {
  position: fixed; z-index: 8; top: 92px; right: 16px; width: 380px;
  max-height: calc(100dvh - 200px); overflow: auto;
  padding: 24px; border-radius: var(--r-panel);
  background: var(--surface); box-shadow: var(--shadow);
}
.card-close {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--hairline); background: var(--surface);
  font-size: 20px; line-height: 1; color: var(--ink-soft); cursor: pointer;
}
.card h2 { margin: 0 6px 2px 0; font: 600 22px/1.15 Onest, sans-serif; }
.card .sub { margin: 0 0 18px; font: 500 13px/1.3 Onest, sans-serif; color: var(--ink-soft); }
.card .big { font: 600 clamp(2rem, 4vw, 2.6rem)/1 Unbounded, Onest, sans-serif; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; }
.row + .row { border-top: 1px solid var(--hairline); }
.row .k { font: 500 13px/1 Onest, sans-serif; color: var(--ink-soft); }
.row .v { font: 600 16px/1 Onest, sans-serif; }
.hero {
  margin: 0 0 16px; padding: 18px 20px; border-radius: var(--r-panel);
  background: var(--paper);
}
.hero .k { font: 500 12px/1 Onest, sans-serif; color: var(--ink-soft); }
.warn {
  margin-top: 14px; padding: 14px 16px; border-radius: var(--r-panel);
  background: #fdf3ea; font: 600 16px/1.35 Onest, sans-serif;
}
.hotel { display: flex; gap: 12px; align-items: center; padding: 12px 0; }
.hotel + .hotel { border-top: 1px solid var(--hairline); }
.hotel a { color: var(--brand); text-decoration: none; font-weight: 600; }
.muted { font: 500 12px/1.35 Onest, sans-serif; color: var(--ink-soft); }
.boot {
  position: fixed; z-index: 9; left: 50%; top: 16px; transform: translateX(-50%);
  padding: 10px 20px; border-radius: var(--r-pill);
  background: var(--ink); color: #fff; box-shadow: var(--shadow);
  font: 600 13px/1 Onest, sans-serif;
}
.boot[hidden] { display: none; }
  .card { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 62dvh;
          border-radius: var(--r-panel) var(--r-panel) 0 0; }
  .controls { width: 100%; max-width: none; }
  .puck-name { display: none; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
/* Стартовый экран: сначала откуда, дата и время, потом уже поиск по Tutu. */
.gate {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: var(--paper);
}
.gate[hidden] { display: none; }
.gate-card {
  display: flex; flex-direction: column; gap: 12px;
  width: min(420px, calc(100vw - 32px));
  padding: 36px 32px 32px;
  background: var(--surface); border-radius: var(--r-panel);
  box-shadow: var(--shadow);
}
.gate-title { margin: 0; font: 600 clamp(2.4rem, 7vw, 3.4rem)/1 Unbounded, Onest, sans-serif; }
.gate-sub { margin: 0 0 14px; font: 500 14px/1 Onest, sans-serif; color: var(--ink-soft); }
.gate-field { justify-content: space-between; height: 52px; width: 100%; }
.gate-k { font: 500 13px/1 Onest, sans-serif; color: var(--ink-soft); }
.gate-field select, .gate-field input {
  height: 48px; border: 0; background: none; color: var(--ink);
  font: 600 17px/1 Onest, sans-serif; text-align: right; cursor: pointer; appearance: none;
}
.gate-field select:focus-visible, .gate-field input:focus-visible { outline: none; }
.gate-go {
  height: 60px; margin-top: 10px; justify-content: center;
  background: var(--brand); border-color: var(--brand); color: #fff;
  font: 600 18px/1 Onest, sans-serif;
}
.gate-go:active { background: var(--brand-press); }
.puck-dot { min-width: 12px; min-height: 12px; }
/* Выбор города: алфавитный список с поиском, в той же круглой геометрии. */
.gate-pair { display: flex; gap: 6px; align-items: center; }
.gate-pair input { text-align: right; }
#gate-city { justify-content: space-between; }
.picker {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: rgba(22, 20, 60, 0.28); backdrop-filter: blur(4px);
}
.picker[hidden] { display: none; }
.picker-card {
  display: flex; flex-direction: column; gap: 10px;
  width: min(400px, calc(100vw - 32px)); max-height: min(70dvh, 560px);
  padding: 18px; border-radius: var(--r-panel);
  background: var(--surface); box-shadow: var(--shadow);
}
#picker-input {
  height: 48px; padding: 0 20px; flex: none;
  border: 1px solid var(--hairline); border-radius: var(--r-pill);
  background: var(--paper); color: var(--ink);
  font: 600 16px/1 Onest, sans-serif;
}
#picker-input:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.picker-list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.picker-row {
  display: flex; align-items: baseline; gap: 8px; justify-content: space-between;
  padding: 11px 18px; border: 0; border-radius: var(--r-pill);
  background: none; color: var(--ink); text-align: left; cursor: pointer;
  font: 600 15px/1 Onest, sans-serif;
}
.picker-row:hover, .picker-row:focus-visible { background: var(--paper); outline: none; }
.picker-row span { font: 500 12px/1 Onest, sans-serif; color: var(--ink-soft); }
.picker-letter {
  padding: 10px 18px 4px; font: 600 12px/1 Onest, sans-serif;
  color: var(--brand); letter-spacing: 0.06em;
}
.picker-close { justify-content: center; flex: none; }
/* Рейс целиком: время, транспорт, станции. */
.leg { padding: 12px 0; border-top: 1px solid var(--hairline); }
.leg-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.leg-top .k { font: 500 13px/1 Onest, sans-serif; color: var(--ink-soft); }
.leg-top .v { font: 600 17px/1 Onest, sans-serif; }
.leg-mid { margin-top: 6px; font: 600 13px/1.2 Onest, sans-serif; color: var(--brand); }
.leg-route { margin-top: 4px; font: 500 12px/1.35 Onest, sans-serif; color: var(--ink-soft); }
.buy { width: 100%; margin-top: 14px; justify-content: center; text-decoration: none;
       background: var(--brand); border-color: var(--brand); color: #fff; }
.asked { margin: 0 0 6px; font: 500 13px/1.35 Onest, sans-serif; color: var(--brand); }

/* Экран карты: кнопка возврата к настройкам, чат, карточка. */
.edit-btn {
  position: fixed; z-index: 6; top: 16px; left: 16px;
}
.edit-btn::after { content: '·'; margin-left: 4px; color: var(--ink-soft); }
.dot-home {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.18);
}

.chatbar {
  position: fixed; z-index: 6; left: 16px; bottom: 16px;
  display: flex; flex-direction: column; gap: 8px;
  width: min(440px, calc(100vw - 32px));
}
.chat-head {
  align-self: flex-start;
  padding: 8px 16px; border-radius: var(--r-pill);
  background: var(--surface); box-shadow: var(--shadow-soft);
  font: 500 13px/1 Onest, sans-serif; color: var(--ink-soft);
}
.chat-head b { font: 600 15px/1 Onest, sans-serif; color: var(--ink); }

.gate-group { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.gate-group .gate-k { padding-left: 6px; }
.gate-pair { display: flex; gap: 6px; align-items: center; }
.gate-pair input { text-align: right; }
#gate-city { justify-content: space-between; }
#gate-city-name { font: 600 17px/1 Onest, sans-serif; }
.gate-field input {
  height: 46px; border: 0; background: none; color: var(--ink);
  font: 600 16px/1 Onest, sans-serif; cursor: pointer;
}
.gate-field input:focus-visible { outline: none; }

@media (max-width: 767px) {
  .chatbar { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .edit-btn { top: 12px; left: 12px; }
}


/* Двусторонний ползунок: обе границы задаются пальцем. */
.range-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px; }
.range-head span:last-child { font: 600 14px/1 Onest, sans-serif; color: var(--ink); }
.range { position: relative; height: 44px; padding: 0 12px; }
.range-track {
  position: absolute; left: 12px; right: 12px; top: 20px; height: 6px;
  background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--r-pill);
}
.range-fill { position: absolute; top: -1px; bottom: -1px; border-radius: var(--r-pill); background: var(--brand); }
.range input[type='range'] {
  position: absolute; left: 12px; top: 10px; width: calc(100% - 24px);
  margin: 0; height: 26px; background: none; appearance: none; pointer-events: none;
}
.range input[type='range']:focus-visible { outline: none; }
.range input[type='range']::-webkit-slider-thumb {
  appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--brand);
  box-shadow: var(--shadow-soft); cursor: grab; pointer-events: auto;
}
.range input[type='range']::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--brand);
  box-shadow: var(--shadow-soft); cursor: grab; pointer-events: auto;
}
.range input[type='range']:active::-webkit-slider-thumb { background: var(--brand); cursor: grabbing; }


/* Шаги агента: что он реально вызвал. */
.trace { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.trace span {
  padding: 5px 12px; border-radius: var(--r-pill);
  background: var(--paper); border: 1px solid var(--hairline);
  font: 500 11px/1 Onest, sans-serif; color: var(--ink-soft);
}


/* Все рейсы за выбранные даты. */
.routes { margin-top: 14px; }
.routes summary {
  cursor: pointer; list-style: none; padding: 10px 16px;
  border-radius: var(--r-pill); background: var(--paper);
  font: 600 13px/1 Onest, sans-serif; color: var(--ink);
}
.routes summary::-webkit-details-marker { display: none; }
.routes[open] summary { margin-bottom: 4px; }
