/* Дизайн-система календаря.

   Правила, которые держат вёрстку ровной:
   • любой сжимаемый flex-элемент получает min-width:0, иначе длинный текст
     распирает строку и ломает соседей;
   • длинные слова и ссылки переносятся принудительно (overflow-wrap);
   • все интерактивные элементы не меньше 44×44 — норма Apple для пальца;
   • отступы и радиусы берутся только из переменных, без произвольных чисел;
   • нижняя навигация и модальные шторки учитывают safe-area айфона. */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --surface-3: #e6e9ef;
  --line: #e3e6ec;
  --line-soft: #edeff3;
  --fg: #0f1319;
  --fg-2: #59616e;
  --fg-3: #8a919f;

  --accent: #2f6fed;
  --accent-fg: #ffffff;
  --accent-soft: #e8f0fe;
  --ok: #17915a;
  --ok-soft: #e4f5ec;
  --warn: #b8730f;
  --warn-soft: #fdf1de;
  --danger: #d43f31;
  --danger-soft: #fdecea;

  --r-xs: 10px;
  --r-sm: 14px;
  --r: 20px;
  --r-lg: 28px;
  --r-full: 999px;

  /* стеклянные слои: полупрозрачная подложка, светлая кромка, блик */
  --glass: rgba(255, 255, 255, .72);
  --glass-line: rgba(255, 255, 255, .5);
  --glass-blur: saturate(180%) blur(24px);

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 28px; --s7: 40px;

  --tap: 44px;

  --shadow-1: 0 1px 2px rgba(15, 19, 25, .05);
  --shadow-2: 0 2px 6px rgba(15, 19, 25, .06), 0 12px 28px rgba(15, 19, 25, .07);
  --shadow-3: 0 -6px 30px rgba(15, 19, 25, .16);

  --ease: cubic-bezier(.2, .8, .3, 1);
  --spring: cubic-bezier(.16, 1, .3, 1);


  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;

  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --surface: #16191f;
    --surface-2: #1d2128;
    --surface-3: #262b34;
    --line: #262a33;
    --line-soft: #1e222a;
    --fg: #eef1f6;
    --fg-2: #a4acba;
    --fg-3: #6f7787;
    --accent: #4d8dff;
    --accent-soft: #16233a;
    --ok: #2fbd7c;
    --ok-soft: #12281f;
    --warn: #e0a458;
    --warn-soft: #2a2015;
    --danger: #ff6f5f;
    --danger-soft: #2b1715;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, .5), 0 14px 34px rgba(0, 0, 0, .45);
    --shadow-3: 0 -6px 30px rgba(0, 0, 0, .6);
    --glass: rgba(28, 32, 40, .72);
    --glass-line: rgba(255, 255, 255, .09);
  }
}

* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}

/* длинные ссылки, коды и слова не должны распирать карточки */
p, span, div, li, h1, h2, h3, b, strong, em, a, label { overflow-wrap: anywhere; }

img, svg { max-width: 100%; }

/* ─────────── каркас ─────────── */

.app {
  min-height: 100dvh;
  /* запас под полосу навигации, чтобы последний блок не упирался в неё */
  padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px) + var(--s6));
}

/* Верхней полосы нет: контент начинается сразу под Dynamic Island.
   Остров «вырезается» отступом по safe-area — фон уходит под него,
   а текст и кнопки под него не заезжают. */
.topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  gap: var(--s2);
  padding: calc(env(safe-area-inset-top, 0px) + var(--s3)) var(--s4) 0;
  background: none;
  border: 0;
}
.topbar .title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wrap {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: var(--s3) var(--s4) var(--s4);
}
/* если шапки нет вовсе — сами отступаем от острова */
.app > .wrap:first-child { padding-top: calc(env(safe-area-inset-top, 0px) + var(--s4)); }

.head { padding: var(--s1) 0 var(--s4); }
.head h1 {
  margin: 0 0 var(--s1);
  text-wrap: balance;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.025em;
}
.head p { margin: 0; color: var(--fg-2); font-size: 14.5px; text-wrap: pretty; }

h2 {
  margin: var(--s6) 0 var(--s3);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--fg-3);
}
h2:first-child { margin-top: 0; }

.sub { color: var(--fg-2); font-size: 14.5px; margin: 0 0 var(--s4); }
.muted { color: var(--fg-3); font-size: 13px; text-wrap: pretty; }

/* ─────────── экраны ─────────── */

.step { display: none; }
.step.on { display: block; animation: screen-in .26s var(--ease) both; }
@keyframes screen-in {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: none; }
}

.stagger > * { animation: item-in .3s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .05s; }
.stagger > *:nth-child(3) { animation-delay: .08s; }
.stagger > *:nth-child(4) { animation-delay: .11s; }
.stagger > *:nth-child(5) { animation-delay: .14s; }
.stagger > *:nth-child(n+6) { animation-delay: .16s; }
@keyframes item-in {
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
  to { opacity: 1; transform: none; }
}

/* ─────────── карточки ─────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  .card { box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, .04); }
}
.card + .card { margin-top: var(--s3); }
.card.pad { padding: var(--s4); }

.rows > * { border-bottom: 1px solid var(--line-soft); }
.rows > *:last-child { border-bottom: 0; }

/* строка списка: полоска — контент — хвост */
.row-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 56px;
  padding: var(--s3) var(--s4);
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
}
.row-item .bar {
  flex: 0 0 auto;
  width: 4px;
  align-self: stretch;
  min-height: 32px;
  border-radius: var(--r-full);
  background: var(--fg-3);
}
.row-item .body { flex: 1 1 auto; min-width: 0; }
.row-item .name {
  font-weight: 560;
  font-size: 15px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row-item .meta {
  margin-top: 3px;
  color: var(--fg-2);
  font-size: 13px;
  line-height: 1.35;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.row-item .tail {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s1);
  color: var(--fg-2);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.row-item.tappable { cursor: pointer; transition: background .15s var(--ease); }
.row-item.tappable:active { background: var(--surface-2); }

/* строка «ключ — значение» */
.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: var(--tap);
  padding: var(--s2) var(--s4);
}
.kv .k { flex: 1 1 auto; min-width: 0; color: var(--fg-2); font-size: 14.5px; }
.kv .v {
  flex: 0 1 auto;
  min-width: 0;
  text-align: right;
  font-weight: 560;
  font-size: 14.5px;
}
.kv .v input, .kv .v select { max-width: 100%; }

/* ─────────── геолокация и маршрут ─────────── */

#travelBar { margin: var(--s3) 0; }
#locBtn { margin-bottom: var(--s3); font-size: 14px; }
#travelBar .rows { gap: var(--s2); }

/* ─────────── кнопки ─────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s5);
  border: 0;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-fg);
  font: 640 16px var(--font);
  cursor: pointer;
  transition: transform .12s var(--ease), opacity .15s, background .15s;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active { transform: scale(.965); filter: brightness(.96); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.block { display: flex; width: 100%; }
.btn.tonal { background: var(--surface-2); color: var(--fg); }
.btn.ghost { background: transparent; color: var(--accent); font-weight: 560; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn.ok { background: var(--ok); }
/* компактная кнопка остаётся «пальцевой»: уже, но не ниже нормы */
.btn.sm { min-height: var(--tap); padding: 0 var(--s4); font-size: 14.5px;
          border-radius: var(--r-xs); }

/* круглая иконочная кнопка — всегда 44×44 */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--fg-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, transform .12s var(--ease);
}
.icon-btn:active { transform: scale(.9); background: var(--surface-2); }
.icon-btn.filled { background: var(--surface-2); color: var(--fg); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.btn-row > .btn { flex: 1 1 auto; min-width: 120px; }

/* ─────────── нижняя навигация ───────────

   Внешний .nav — прозрачная зона, которая забирает на себя safe-area.
   Стеклянная капсула живёт внутри и о нижнем индикаторе ничего не знает:
   именно смешение этих двух ролей раньше «поднимало» кнопки вверх в PWA. */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  box-sizing: border-box;
  padding: 0 var(--s4) calc(env(safe-area-inset-bottom, 0px) + 10px);
  pointer-events: none;            /* клики ловит только капсула */
  background: none;
}

.nav-inner {
  pointer-events: auto;
  display: flex;
  align-items: stretch;
  width: 100%;
  max-width: 440px;
  height: 58px;
  padding: 5px;
  gap: 2px;
  border-radius: var(--r-full);
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line);
  box-shadow:
    0 10px 34px rgba(15, 19, 25, .18),
    0 2px 8px rgba(15, 19, 25, .08),
    inset 0 1px 0 rgba(255, 255, 255, .45);
}

.nav button {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  grid-template-rows: 20px 11px;
  align-content: center;
  justify-items: center;
  gap: 3px;
  border: 0;
  border-radius: var(--r-full);
  background: none;
  color: var(--fg-3);
  font: 550 9.5px/1 var(--font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .22s var(--ease);
}

/* Подсветка активной вкладки — отдельный слой под содержимым: он плавно
   переезжает вместе с выбором и не может вылезти за края капсулы. */
.nav button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  opacity: 0;
  transform: scale(.86);
  transition: opacity .24s var(--ease), transform .32s var(--spring);
}
.nav button[aria-selected="true"]::before { opacity: 1; transform: scale(1); }
.nav button[aria-selected="true"] { color: var(--accent); }
.nav button:active::before { opacity: .6; transform: scale(.94); }

.nav button .ico {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 18px;
  line-height: 1;
  transition: transform .3s var(--spring);
}
.nav button[aria-selected="true"] .ico { transform: scale(1.06); }

.nav button span.lbl {
  display: block;
  width: 100%;
  height: 11px;
  line-height: 11px;
  text-align: center;
  letter-spacing: -.01em;
  overflow: hidden;
  white-space: nowrap;
  opacity: .95;
}

.nav button .dot {
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(7px);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--glass);
}

/* совсем узкие экраны — только значки, капсула ниже */
@media (max-width: 360px) {
  .nav-inner { height: 52px; }
  .nav button { grid-template-rows: 24px; }
  .nav button span.lbl { display: none; }
  .nav button .ico { width: 24px; height: 24px; font-size: 21px; }
}

/* ─────────── формы ─────────── */

label {
  display: block;
  font-size: 13px;
  font-weight: 560;
  color: var(--fg-2);
  margin: var(--s4) 0 var(--s2);
  line-height: 1.3;
}
label:first-child { margin-top: 0; }
.card.pad > *:first-child { margin-top: 0; }

/* Все поля одной геометрии. Без appearance:none у iOS date/time своя высота
   и свои отступы — в паре колонок они выглядели съехавшими. */
input, textarea, select {
  display: block;
  width: 100%;
  height: 50px;
  min-height: 50px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  font: 400 16px/1.2 var(--font);   /* 16px — иначе iOS зумит поле при фокусе */
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
select {
  padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-3) 50%),
                    linear-gradient(135deg, var(--fg-3) 50%, transparent 50%);
  background-position: calc(100% - 19px) 22px, calc(100% - 14px) 22px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
/* у date/time внутренний блок выравниваем по центру строки */
input[type="date"], input[type="time"], input[type="number"] { text-align: left; }
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { opacity: .5; }
textarea {
  height: auto;
  min-height: 92px;
  padding: 13px 14px;
  line-height: 1.4;
}
/* переключатель вместо стандартного чекбокса: область касания 52×44 */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: var(--tap);
  flex: none;
}
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  min-height: 0;
}
.switch .track {
  width: 52px;
  height: 31px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  transition: background .22s var(--ease);
}
.switch .knob {
  position: absolute;
  left: 3px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .24s var(--spring);
}
.switch input:checked ~ .track { background: var(--ok); }
.switch input:checked ~ .knob { transform: translateX(21px); }
.switch input:focus-visible ~ .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
input:focus, textarea:focus, select:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}


.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); align-items: end; }
.grid2 > * { min-width: 0; }
.grid2 label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Кнопка никогда не прилипает к тому, что над ней: :has() ловит все случаи
   разом, включая динамически собранные экраны. */
.card + .btn, .card + .btn-row, .grid2 + .btn, input + .btn, select + .btn,
textarea + .btn, .seg + .btn, .card + .seg, h2 + .btn { margin-top: var(--s4); }
.btn + .btn { margin-top: var(--s2); }
/* …но только когда кнопки стоят стопкой. В горизонтальных рядах расстояние
   держит gap, а лишний margin-top опускал вторую кнопку и делал её ниже
   первой — пара выглядела кривой в каждой шторке с двумя действиями. */
:is(.sheet-foot, .btn-row, .kv, .banner, .seg, .search-bar) > .btn + .btn {
  margin-top: 0;
}
.card + h2 { margin-top: var(--s6); }
:is(.card, .rows, .grid2, .slots, .seg, .empty) + :is(.btn, .btn-row) {
  margin-top: var(--s4);
}
/* карточка, внутри которой только поля, снизу не режет последнее поле */
.card.pad:has(> input:last-child, > select:last-child, > textarea:last-child) {
  padding-bottom: var(--s4);
}

.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.seg button {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--tap);
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--fg-2);
  font: 600 14px var(--font);
  cursor: pointer;
  transition: background .18s var(--ease), color .18s;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-1);
}

/* ─────────── чек и чипы ─────────── */

.check {
  position: relative;
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.check::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 9px;
  border: 2px solid var(--line);
  background: var(--surface);
  transition: all .2s var(--spring);
}
.check::after {
  content: "✓";
  position: absolute;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  opacity: 0;
  transform: scale(.4);
  transition: all .22s var(--spring);
}
.check:active::before { transform: scale(.88); }
.check.on::before { background: var(--ok); border-color: var(--ok); }
.check.on::after { opacity: 1; transform: scale(1); }
.check.skip::before { background: var(--surface-3); border-color: var(--line); }
.check.skip::after { content: "✕"; color: var(--fg-3); opacity: 1; transform: scale(1); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: 12px;
  font-weight: 560;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

.quote {
  margin: var(--s2) 0 0;
  padding: var(--s2) var(--s3);
  border-left: 3px solid var(--line);
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: 14px;
}

/* ─────────── календарь ─────────── */

.cal { padding: var(--s3); }
.calhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.calhead b {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 640;
  text-transform: capitalize;
}

.grid7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.wd {
  text-align: center;
  color: var(--fg-3);
  font-size: 11px;
  font-weight: 640;
  padding: 6px 0;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.day {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 40px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--fg-3);
  font: 500 14px var(--font);
  cursor: default;
  transition: background .15s, transform .12s var(--ease);
}
.day.free { color: var(--fg); cursor: pointer; font-weight: 640; background: var(--surface-2); }
.day.free:active { transform: scale(.9); }
.day.has::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  display: flex;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.day.sel { background: var(--accent); color: var(--accent-fg); }
.day.sel::after { background: var(--accent-fg); }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--s2); }
.slot {
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  font: 640 15px var(--font);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform .12s var(--ease), border-color .15s, background .15s;
}
.slot:active { transform: scale(.95); }
.slot.sel { background: var(--accent); color: var(--accent-fg); border-color: transparent; }

/* ─────────── модальная шторка ─────────── */

/* ─────────── поиск ─────────── */

.search-pane {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: searchIn .26s var(--spring);
}
.search-pane[hidden] { display: none; }
@keyframes searchIn {
  from { opacity: 0; transform: scale(1.02); }
  to   { opacity: 1; transform: none; }
}
.search-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s2);
  box-sizing: border-box;
  padding: calc(env(safe-area-inset-top, 0px) + var(--s3)) var(--s4) var(--s3);
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--line-soft);
}
.search-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s2);
  box-sizing: border-box;
  height: 44px;
  padding: 0 var(--s3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.search-ico { flex: none; font-size: 15px; opacity: .55; }
.search-field input {
  flex: 1;
  min-width: 0;
  height: 42px;                 /* поле уже внутри капсулы — своя рамка не нужна */
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font-size: 17px;
  color: var(--fg);
}
.search-field input:focus { outline: none; box-shadow: none; }
.search-field input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-bar .btn { flex: none; }
.search-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--s4) var(--s4) calc(env(safe-area-inset-bottom, 0px) + var(--s7));
}
.search-body > *:first-child { margin-top: 0; }

/* ─────────── плавающая кнопка ───────────
   Живёт над капсулой навигации: та занимает 58px плюс safe-area. */

.fab {
  position: fixed;
  right: var(--s4);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 78px);
  z-index: 41;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  border: 1px solid var(--glass-line);
  border-radius: var(--r-full);
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-2);
  color: var(--fg);
  cursor: pointer;
  transition: transform .16s var(--spring), opacity .2s;
}
.fab[hidden] { display: none; }
.fab:active { transform: scale(.9); }
.fab:disabled { opacity: .5; }

/* ─────────── поездки и подсказки ─────────── */

.sub-h {
  margin: var(--s4) 0 var(--s2);
  font-size: 14px;
  font-weight: 650;
  color: var(--fg-2);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
}
.chips:empty { display: none; }

/* Блок одной поездки или подсказки: своя рамка, чтобы соседние карточки
   не сливались в одну простыню. */
.trip {
  box-sizing: border-box;
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line-soft);
}
.trip:last-child { border-bottom: 0; padding-bottom: 0; }
.trip:first-child { padding-top: 0; }
.trip-head {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  margin-bottom: var(--s2);
}
.trip-head .nm {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trip-head .val {
  flex: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}
.trip .btn-row { margin-top: var(--s3); }
.trip a.btn { text-decoration: none; }

.quote {
  margin: var(--s2) 0 0;
  padding: var(--s2) var(--s3);
  border-left: 3px solid var(--line);
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: 14px;
  text-wrap: pretty;
}

/* ─────────── отчёт по времени ─────────── */

.stat-big {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  padding: var(--s2) 0 var(--s3);
}
.stat-big b { font-size: 34px; line-height: 1; letter-spacing: -.02em; }
.stat-big span { color: var(--fg-2); font-size: 14px; }
.stat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s1) var(--s3);
  align-items: center;
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line-soft);
}
.stat-row:last-child { border-bottom: 0; }
.stat-row .nm {
  min-width: 0;
  font-size: 15px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-row .val {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-row .track {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  overflow: hidden;
}
.stat-row .fill {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  transform-origin: left center;
  /* backwards, а не both: если анимация не отработает (фоновая вкладка,
     прерванный рендер), полоска останется полной, а не исчезнет */
  animation: barGrow .5s var(--spring) backwards;
}
@keyframes barGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.sheet-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 10, 14, .45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}
.sheet-back.on { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 51;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--glass-line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-3);
  transform: translate3d(0, 100%, 0);
  transition: transform .34s var(--spring);
}
.sheet.on { transform: none; }
.sheet .grip {
  flex: none;
  width: 38px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: var(--r-full);
  background: var(--line);
}
.sheet .sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s4) var(--s2);
}
.sheet .sheet-head h3 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 18px;
  font-weight: 660;
  letter-spacing: -.02em;
}
.sheet .sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--s4) var(--s4);
}
.sheet .sheet-foot {
  flex: none;
  display: flex;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  padding-bottom: calc(var(--s3) + var(--sab));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.sheet .sheet-foot > .btn { flex: 1 1 auto; }

/* ─────────── состояния ─────────── */

.empty {
  text-wrap: pretty;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s7) var(--s4);
  text-align: center;
  color: var(--fg-3);
  font-size: 14px;
}
.empty .ico { font-size: 34px; opacity: .55; }

.banner {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-sm);
  font-size: 14px;
  margin-bottom: var(--s3);
}
.banner.info { background: var(--accent-soft); color: var(--fg); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner .grow { flex: 1; min-width: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(56px + var(--sab) + var(--s4));
  z-index: 60;
  transform: translate(-50%, 20px);
  max-width: min(92vw, 460px);
  padding: 11px var(--s4);
  border-radius: var(--r-full);
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  font-weight: 560;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .28s var(--spring);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); color: #fff; }

.spin {
  display: inline-block;
  width: 17px;
  height: 17px;
  vertical-align: -3px;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: sp .7s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

.skel {
  height: 62px;
  margin-bottom: var(--s2);
  border-radius: var(--r);
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--line) 50%, var(--surface-2) 70%);
  background-size: 300% 100%;
  animation: sh 1.4s ease-in-out infinite;
}
@keyframes sh { from { background-position: 200% 0; } to { background-position: -100% 0; } }

/* индикатор «потяни, чтобы обновить» */
.ptr {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 0;
  overflow: hidden;
  color: var(--fg-3);
  transition: height .2s var(--ease);
}
.ptr.on { height: 40px; }

.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ─────────── линейка iPhone ───────────
   Ширины в CSS-пикселях: SE/8 — 375, 13 mini — 375, 14/15/15 Pro — 393,
   15 Plus / Pro Max — 430. Ниже — только то, что реально меняет посадку. */

/* SE, mini и всё, что уже 380 */
@media (max-width: 380px) {
  :root { --s4: 13px; --s5: 16px; }
  .head h1 { font-size: 23px; }
  .nav-inner { height: 48px; }
  .row-item { gap: var(--s2); padding: var(--s3); }
  .row-item .tail { font-size: 13px; }
  .kv { padding: var(--s2) var(--s3); }
  .slots { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
}

/* 14 / 15 / 15 Pro — базовая посадка, чуть просторнее подписи */
@media (min-width: 381px) and (max-width: 413px) {
}

/* Plus и Pro Max — больше воздуха, контент не расползается */
@media (min-width: 414px) {
  :root { --s4: 18px; --s5: 22px; }
  .wrap { max-width: 640px; }
  .head h1 { font-size: 28px; }
}

/* Dynamic Island и «чёлка»: у топбара уже есть отступ по safe-area,
   но при нулевом env нужен разумный минимум, иначе заголовок жмётся к краю.
   Навигация использует max() в bottom напрямую — второй раз padding не нужен. */
@supports (padding: max(0px)) {
  .topbar { padding-top: max(calc(var(--s2) + var(--sat)), var(--s3)); }
  .sheet .sheet-foot { padding-bottom: max(calc(var(--s3) + var(--sab)), var(--s4)); }
}

/* Ландшафт на телефоне: экран низкий, шапке и шторке нужно ужаться */
@media (max-height: 480px) and (orientation: landscape) {
  .head { padding-bottom: var(--s2); }
  .head h1 { font-size: 20px; }
  .sheet { max-height: 96dvh; }
}

/* Планшет и десктоп — просто центрируем, навигация остаётся внизу */
@media (min-width: 760px) {
  .wrap { max-width: 700px; }
  .nav { max-width: 560px; }
}

/* ─────────── финальная полировка ─────────── */

/* Переходы между вкладками: контент «приезжает» снизу и слегка проявляется. */
.step.on { animation: screen-in .3s var(--spring) both; }
@keyframes screen-in {
  from { opacity: 0; transform: translate3d(0, 12px, 0) scale(.995); }
  to { opacity: 1; transform: none; }
}

/* Крупный заголовок как в системных приложениях */
.head h1 { font-size: 30px; letter-spacing: -.03em; line-height: 1.08; }
@media (max-width: 380px) { .head h1 { font-size: 26px; } }

/* Карточки чуть живее на нажатие */
.card { transition: transform .18s var(--ease), box-shadow .18s var(--ease); }
.row-item.tappable:active { background: var(--surface-2); }
.card:has(.row-item.tappable:active) { transform: scale(.995); }

/* Полоска слева у строки — мягче и заметнее */
.row-item .bar { width: 3.5px; opacity: .9; }

/* Разделители не доходят до края — как в списках iOS */
.rows > *:not(:last-child) {
  border-bottom: 1px solid var(--line-soft);
  background-clip: padding-box;
}

/* Шторка приезжает мягче и с чуть большим радиусом */
.sheet { border-radius: 30px 30px 0 0; }
.sheet.on { transition: transform .42s var(--spring); }
.grip { transition: background .2s; }
.sheet.on .grip { background: var(--line-strong, var(--line)); }

/* Кнопки: приятный отклик без резкости */
.btn { transition: transform .14s var(--spring), opacity .15s, background .18s, filter .18s; }
.btn:active { transform: scale(.97); }
.icon-btn:active { transform: scale(.88); }

/* Чипы не прыгают по высоте */
.chip { min-height: 22px; }

/* Тост поднимается над капсулой навигации */
.toast { bottom: calc(58px + env(safe-area-inset-bottom, 0px) + var(--s5)); }

/* Пустые состояния — спокойнее */
.empty .ico { opacity: .4; }

/* Загрузка: скелетоны в тон карточкам */
.skel { border-radius: var(--r); }

/* Фокус с клавиатуры виден, мышью — нет */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
