/* Стиль Sayohat: синий, оранжевая кнопка поиска, Manrope + Unbounded, мягкие тени. Тёмная тема — как в Telegram. */
:root {
  --bg: #F4F2EC;
  --surface: #FFFFFF;
  --surface-2: #F8F7F3;
  --line: #E6E2D8;
  --text: #121826;
  --muted: #6A7183;
  --primary: #2F6BFF;
  --primary-soft: #E8EFFF;
  --accent: #FF5A36;
  --accent-dark: #E8441F;
  --good: #0E9F6E;
  --good-soft: #E3F6EE;
  --bad: #D93025;
  --hero: linear-gradient(160deg, #2F6BFF 0%, #1D4FD8 60%, #173FB0 100%);
  --shadow: 0 1px 2px rgba(14, 26, 43, .06), 0 8px 24px rgba(14, 26, 43, .07);
  --shadow-lg: 0 -10px 40px rgba(14, 26, 43, .18);
  --radius: 18px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Unbounded", "Manrope", system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0A111D;
  --surface: #121B2B;
  --surface-2: #172234;
  --line: #233148;
  --text: #E9EDF5;
  --muted: #8E99AE;
  --primary: #6F98FF;
  --primary-soft: #1B2A47;
  --good: #34D399;
  --good-soft: #10302A;
  --bad: #FF6B6B;
  --hero: linear-gradient(160deg, #1A2D55 0%, #13213F 60%, #0E1830 100%);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  --shadow-lg: 0 -10px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
/* Иконки (icons.js): размер от шрифта, цвет — текущий */
.ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.ic.star { color: #F5B301; }
.set-h .ic, .tabs .ic { color: var(--primary); }
.tabs button.on .ic { color: #173FB0; }
.tabs .ic { color: inherit; }
.empty b .ic { width: 40px; height: 40px; color: var(--muted); }
.suggest .ico .ic { color: var(--primary); }
.watch-card .bell .ic { width: 22px; height: 22px; color: var(--primary); }
.watch-card.on .bell .ic { color: var(--good); }
.plan-now .ic { color: var(--good); }
.x .ic, .clear .ic, .icon .ic { width: 16px; height: 16px; }
.delta .ic { width: 14px; height: 14px; vertical-align: -2px; }

/* ---------- Шапка ---------- */
.hero {
  background: var(--hero);
  color: #fff;
  padding: 10px 16px 64px;
}
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(255,255,255,.14); max-width: 420px; margin: 0 auto; }
.tabs button { flex: 1; padding: 9px 6px; border-radius: 10px; font-weight: 700; color: rgba(255,255,255,.8); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tabs button.on { background: #fff; color: #173FB0; }
.count { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; line-height: 20px; }
.hero h1 { font: 700 22px/1.2 var(--display); margin: 20px 0 4px; text-align: center; letter-spacing: -.01em; }
.hero-sub { margin: 0; text-align: center; opacity: .8; font-size: 14px; }

main { padding: 0 12px 28px; max-width: 640px; margin: -48px auto 0; position: relative; }

/* ---------- Форма поиска ---------- */
.search { background: var(--surface); border-radius: 22px; padding: 10px; box-shadow: var(--shadow); position: relative; }
.grp { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; position: relative; }
.fld { display: flex; flex-direction: column; justify-content: center; min-height: 58px; padding: 8px 14px; text-align: left; position: relative; width: 100%; }
.cap { font-size: 12px; color: var(--muted); font-weight: 600; }
.val { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.val.placeholder { color: var(--muted); font-weight: 600; }
.fld input { border: 0; outline: 0; background: none; padding: 2px 44px 0 0; font-size: 16px; font-weight: 700; width: 100%; }
.fld input::placeholder { color: var(--muted); font-weight: 600; }
.code { position: absolute; right: 56px; bottom: 11px; color: var(--muted); font-size: 13px; font-weight: 700; }
.route .fld + .fld { border-top: 1px solid var(--line); }
.swap {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--primary); box-shadow: var(--shadow);
  transition: transform .25s;
}
.swap.spin { transform: translateY(-50%) rotate(180deg); }

.dates { display: flex; }
.dates > * { flex: 1; min-width: 0; }
.dates > * + * { border-left: 1px solid var(--line); }
.ret-fld { flex-direction: row; align-items: stretch; padding: 0; }
.ret-open { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 8px 14px; text-align: left; }
.clear { width: 40px; color: var(--muted); font-size: 14px; }
.wide { flex-direction: column; padding-right: 36px; }
.chev { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 22px; }

.cta {
  display: block; width: 100%; border-radius: 14px; padding: 16px; margin-top: 2px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .1s, background .15s;
}
.cta:active { transform: scale(.98); background: var(--accent-dark); }
.cta:disabled { opacity: .6; }

.suggest {
  position: absolute; left: 10px; right: 10px; z-index: 20; margin-top: -4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
}
.suggest button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; text-align: left; }
.suggest button + button { border-top: 1px solid var(--line); }
.suggest button:active, .suggest button.hl { background: var(--primary-soft); }
.suggest .ico { width: 32px; height: 32px; border-radius: 10px; background: var(--primary-soft); display: grid; place-items: center; flex: none; }
.suggest .nm { flex: 1; min-width: 0; }
.suggest .nm b { display: block; font-weight: 700; }
.suggest .nm span { color: var(--muted); font-size: 13px; }
.suggest em { font-style: normal; color: var(--muted); font-weight: 700; font-size: 13px; }

/* ---------- Результаты ---------- */
#results { margin-top: 16px; }
.res-head { padding: 4px 4px 10px; }
.res-route { font: 700 18px/1.25 var(--display); }
.muted { color: var(--muted); font-size: 13px; }
.sorts { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.sorts::-webkit-scrollbar { display: none; }
.sorts button { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 14px; }
.sorts button.on { background: var(--text); color: var(--surface); border-color: var(--text); }

.watch-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.watch-card .bell { width: 42px; height: 42px; border-radius: 12px; background: var(--primary-soft); display: grid; place-items: center; font-size: 20px; flex: none; }
.watch-card .txt { flex: 1; min-width: 0; }
.watch-card .txt b { display: block; }
.watch-card.on .bell { background: var(--good-soft); }
.watch-form { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.opt { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.opt input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; }
.opt input[type=number] { width: 120px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; }

.btn { border-radius: 12px; padding: 10px 16px; font-weight: 700; font-size: 14px; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.soft, .ghost { background: var(--primary-soft); color: var(--primary); }
.ghost { border-radius: 12px; padding: 13px 16px; font-weight: 700; width: 100%; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.ticket { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer; transition: transform .1s; }
.ticket:active { transform: scale(.985); }
.t-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.price { font: 700 22px/1.1 var(--display); color: var(--text); white-space: nowrap; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; text-align: right; }
.logo img { width: 32px; height: 32px; border-radius: 8px; background: #fff; object-fit: contain; border: 1px solid var(--line); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 4px; }
.badge { padding: 3px 8px; border-radius: 8px; font-size: 12px; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
.badge.good { background: var(--good-soft); color: var(--good); }
.leg { padding-top: 12px; }
.leg + .leg { margin-top: 12px; border-top: 1px dashed var(--line); }
.leg-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.pt b { display: block; font-size: 19px; font-weight: 800; }
.pt b sup { font-size: 11px; color: var(--accent); margin-left: 2px; }
.pt span { color: var(--muted); font-size: 12px; font-weight: 700; }
.pt.r { text-align: right; }
.track { text-align: center; color: var(--muted); font-size: 12px; font-weight: 600; }
.track .ln { position: relative; height: 2px; margin: 5px 0; background: var(--line); border-radius: 2px; }
.track .ln::before, .track .ln::after { content: ""; position: absolute; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.track .ln::before { left: 0; } .track .ln::after { right: 0; }
.track .ln i { position: absolute; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); transform: translateX(-50%); }
.track .direct { color: var(--good); }
.leg-date { color: var(--muted); font-size: 12px; font-weight: 600; margin-top: 4px; }
.buy { margin-top: 14px; display: flex; justify-content: flex-end; }
.buy span { background: var(--accent); color: #fff; border-radius: 10px; padding: 8px 14px; font-weight: 800; font-size: 14px; }

.all-link { display: block; text-align: center; padding: 14px; color: var(--primary); font-weight: 700; cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 34px 18px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty b { display: block; font-size: 36px; margin-bottom: 8px; }
.skeleton { height: 128px; border-radius: var(--radius); margin-bottom: 10px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Отслеживания ---------- */
#watches { padding-top: 4px; }
.watch { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.w-head { display: flex; justify-content: space-between; gap: 10px; }
.w-route { font: 700 16px/1.25 var(--display); }
.w-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin: 12px 0 2px; }
.w-price .price { font-size: 24px; }
.delta { font-size: 13px; font-weight: 800; padding: 2px 8px; border-radius: 8px; }
.delta.down { color: var(--good); background: var(--good-soft); }
.delta.up { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.w-meta { font-size: 13px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.w-err { font-size: 13px; color: var(--bad); margin-top: 4px; }
.spark { display: block; width: 100%; height: 52px; margin: 10px 0 2px; }
.spark polyline { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark polygon { fill: var(--primary-soft); }
.w-actions { display: flex; gap: 8px; margin-top: 14px; }
.w-actions .btn { flex: 1; }
.icon { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); color: var(--muted); flex: none; }

/* ---------- Шторки ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-bg { position: absolute; inset: 0; background: rgba(8, 14, 26, .45); animation: fade .2s; }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: up .25s cubic-bezier(.2,.8,.2,1);
  max-width: 640px; margin: 0 auto;
}
.sheet-body::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 10px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.sheet-title { font: 700 18px/1.25 var(--display); }
.sheet-sub { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 2px; }
.x { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); color: var(--muted); flex: none; }
.sheet-foot { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: var(--surface); padding: 10px 0 2px; }

.pax-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); font-weight: 700; }
.pax-row small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button { width: 38px; height: 38px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-size: 22px; line-height: 1; font-weight: 700; }
.stepper button:disabled { opacity: .35; }
.stepper b { min-width: 16px; text-align: center; font-size: 17px; }
.switch { appearance: none; width: 48px; height: 28px; border-radius: 14px; background: var(--line); position: relative; transition: background .2s; flex: none; margin: 0; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(20px); }
.sub-cap { color: var(--muted); font-size: 13px; font-weight: 700; margin: 16px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chips button { padding: 9px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 700; }
.chips button.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Календарь ---------- */
.cal { height: 92vh; display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; padding: 6px 0 8px; border-bottom: 1px solid var(--line); }
.cal-week .we { color: var(--accent); }
.cal-months { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 12px; }
.cal-month { padding-top: 14px; }
.cal-mhead { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 8px; }
.cal-mhead b { font: 700 15px/1.2 var(--display); text-transform: capitalize; }
.cal-mhead button { color: var(--primary); font-weight: 700; font-size: 13px; padding: 6px 10px; border-radius: 10px; background: var(--primary-soft); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; }
.day { height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 12px; font-weight: 700; font-size: 15px; position: relative; }
.day small { font-size: 10px; font-weight: 700; color: var(--muted); height: 13px; line-height: 13px; }
.day small.cheap { color: var(--good); }
.day.off { color: var(--line); pointer-events: none; }
.day.today::after { content: ""; position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.day.in { background: var(--primary-soft); border-radius: 0; }
.day.sel { background: var(--primary); color: #fff; }
.day.sel small { color: rgba(255,255,255,.85); }
.day.sel.start.has-end { border-radius: 12px 0 0 12px; }
.day.sel.end { border-radius: 0 12px 12px 0; }
.day.sel.start.end { border-radius: 12px; }
.day:not(.off):not(.sel):active { background: var(--surface-2); }
.cal .sheet-foot { position: static; border-top: 1px solid var(--line); padding: 10px 0 calc(12px + env(safe-area-inset-bottom)); }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; z-index: 60;
  background: rgba(14, 26, 43, .94); color: #fff; font-size: 14px; font-weight: 600; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: fade .2s;
}

/* ---------- Настройки ---------- */
.tabs button.icon-tab { flex: 0 0 52px; font-size: 17px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.set-h { font: 700 15px/1.3 var(--display); margin-bottom: 12px; }
.card .chips { margin-bottom: 0; }
.card .pax-row.last { border-bottom: 0; padding-bottom: 2px; }
.home-wrap { position: relative; display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; }
.home-wrap input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 14px; font-size: 16px; font-weight: 700; }
.home-wrap input::placeholder { color: var(--muted); font-weight: 600; }
.home-wrap .suggest { top: calc(100% + 6px); left: 0; right: 0; margin: 0; }
.hint-line { margin-top: 8px; }
.center { text-align: center; padding: 4px 0 8px; }
#setStatus.saved { color: var(--good); }
.plan-now { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; margin-bottom: 12px; }
.plan-now b { font-weight: 800; }
.plan-now.on { background: var(--good-soft); border-color: transparent; }
.plan-now .muted { display: block; margin-top: 4px; font-weight: 600; }
.plan-list { display: flex; flex-direction: column; gap: 8px; }
.plan-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; }
.plan-item .pi { flex: 1; min-width: 0; }
.plan-item .pi b { display: block; font: 700 15px/1.3 var(--display); }
.plan-item .pi span { color: var(--muted); font-size: 13px; font-weight: 600; }
.plan-item .btn { white-space: nowrap; }
.anywhere-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 11px; margin-bottom: 8px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 14px; }
.dir-list { display: flex; flex-direction: column; gap: 8px; }
.dir { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%; }
.dir:active { transform: scale(.985); }
.dir .dn { flex: 1; min-width: 0; }
.dir .dn b { display: block; font: 700 16px/1.25 var(--display); }
.dir .dn span { color: var(--muted); font-size: 13px; font-weight: 600; }
.dir .price { font-size: 18px; }
.extras { display: flex; gap: 8px; margin: 4px 0 12px; }
.extras a { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); color: var(--text); font-weight: 700; font-size: 14px; text-decoration: none; }
.extras a .ic { color: var(--primary); }
.promo-row { display: flex; gap: 8px; }
.promo-row input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; text-transform: uppercase; outline: none; }
.promo-row input:focus { border-color: var(--primary); }
.ref-link { margin: 12px 0; padding: 11px 14px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--line); font-weight: 700; font-size: 14px; word-break: break-all; user-select: all; }
