/* Скинемся. Образы из путешествия: авиапочта, проездной билет, холодная бумага. */

:root {
  --bg: #edf1f7;
  --paper: #ffffff;
  --ink: #0d1b3e;
  --muted: #55627f;
  --line: #d3dae8;
  --line-strong: #aab6d1;
  --primary: #2347f5;
  --on-primary: #ffffff;
  --accent-soft: #e1e8ff;
  --plus: #0b7a5b;
  --plus-bg: #d8f1e8;
  --minus: #c23222;
  --minus-bg: #fbe1dc;
  --stripe-red: #e5483a;
  --stripe-gap: #ffffff;
  --focus: #1a5fd0;
  --font-body: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-display: 'Unbounded', 'Onest', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1226;
    --paper: #111c38;
    --ink: #e8edfb;
    --muted: #9ca9c6;
    --line: #243259;
    --line-strong: #3b4c7d;
    --primary: #8ba0ff;
    --on-primary: #0a1226;
    --accent-soft: #1b2a55;
    --plus: #5fd8b0;
    --plus-bg: #12372e;
    --minus: #ff9a8c;
    --minus-bg: #3f1f1c;
    --stripe-red: #ff7466;
    --stripe-gap: #0a1226;
    --focus: #9db4ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
h1, h2 { font-family: var(--font-display); margin: 0; letter-spacing: -0.02em; line-height: 1.12; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; margin: 0; }
p { margin: 0; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* Авиапочтовая кайма: единственная декоративная полоса на странице */
.airmail {
  height: 8px;
  background: repeating-linear-gradient(
    -45deg,
    var(--stripe-red) 0 14px,
    var(--stripe-gap) 14px 22px,
    var(--primary) 22px 36px,
    var(--stripe-gap) 36px 44px
  );
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1040px; margin: 0 auto; padding: 12px 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
  font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; background: var(--primary); color: var(--on-primary);
  display: inline-flex; align-items: center; justify-content: center;
}
.user { display: flex; align-items: center; gap: 2px; min-width: 0; }
.user-name { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }

.page { max-width: 1040px; margin: 0 auto; padding: 8px 16px 104px; display: flex; flex-direction: column; gap: 28px; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Кнопки и поля */
.btn {
  appearance: none; border: 1.5px solid transparent; border-radius: 12px; min-height: 48px; padding: 0 20px;
  font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-link { background: transparent; color: var(--primary); min-height: 44px; padding: 0 10px; }
.btn-danger { background: transparent; color: var(--minus); border-color: var(--minus); }
.btn-small { min-height: 44px; padding: 0 14px; font-size: 15px; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .legend { font-weight: 600; font-size: 15px; }
.input, select.input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--paper); color: var(--ink); font: inherit;
}
.input:focus { border-color: var(--primary); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1 1 0; min-width: 0; }
.form { display: flex; flex-direction: column; gap: 14px; }
.error { color: var(--minus); font-weight: 600; font-size: 15px; }
.error:empty { display: none; }

.panel {
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 20px; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg); border-radius: 14px; }
.tab {
  flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; cursor: pointer;
}
.tab[aria-pressed='true'] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(13, 27, 62, 0.18); }

/* Аватары */
.avatar {
  --av: #cde7ff;
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--av); color: #0d1b3e;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1;
}
.avatar-sm { width: 30px; height: 30px; font-size: 12px; }
.avatar-stack { display: flex; align-items: center; }
.avatar-stack .avatar { border: 2px solid var(--bg); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.panel .avatar-stack .avatar, .trip-card .avatar-stack .avatar { border-color: var(--paper); }
.avatar-more { background: var(--accent-soft); color: var(--ink); font-family: var(--font-body); font-weight: 700; }

/* Лендинг и приглашение */
.landing { display: grid; gap: 28px; padding-top: 8px; }
.landing-copy { display: flex; flex-direction: column; gap: 18px; align-items: flex-start; min-width: 0; }
.hero-title { font-size: 34px; line-height: 1.08; max-width: 14ch; }
.lead { color: var(--muted); font-size: 18px; max-width: 46ch; }
.sample { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 8px; }

/* Билет: «кто кому переводит» */
.tickets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ticket {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; overflow: hidden;
  background: var(--paper); border: 1.5px solid var(--line-strong); border-radius: 16px;
}
.ticket-mine { border-color: var(--primary); }
.ticket-route { display: flex; align-items: center; gap: 8px; padding: 16px 16px; min-width: 0; }
.ticket-person { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; max-width: 40%; }
.ticket-name { font-weight: 600; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-line { flex: 1 1 24px; min-width: 24px; position: relative; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.ticket-line::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px dashed currentColor; opacity: 0.55; }
.ticket-line svg { position: relative; background: var(--paper); padding: 0 4px; box-sizing: content-box; }
.ticket-stub {
  position: relative; display: flex; flex-direction: column; justify-content: center; align-items: flex-end; gap: 2px;
  padding: 14px 16px; min-width: 104px; border-left: 2px dashed var(--line-strong);
}
.ticket-stub::before, .ticket-stub::after {
  content: ''; position: absolute; left: -12px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--line-strong);
}
.ticket-mine .ticket-stub::before, .ticket-mine .ticket-stub::after { border-color: var(--primary); }
.ticket-stub::before { top: -12px; }
.ticket-stub::after { bottom: -12px; }
.ticket-label { font-size: 13px; color: var(--muted); }
.ticket-sum { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.02em; white-space: nowrap; }
.ticket-empty { color: var(--muted); padding: 4px 0; }

/* Главная: поездки */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.trip-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.trip-card {
  display: flex; flex-direction: column; gap: 16px; height: 100%; text-decoration: none; color: inherit;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 20px; padding: 20px;
}
.trip-card:hover { border-color: var(--primary); }
.trip-card h2 { font-size: 20px; overflow-wrap: anywhere; }
.trip-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: auto; }
.chip { display: inline-block; padding: 5px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--accent-soft); color: var(--ink); }
.chip-plus { background: var(--plus-bg); color: var(--plus); }
.chip-minus { background: var(--minus-bg); color: var(--minus); }

.newtrip { background: var(--paper); border: 1.5px solid var(--line); border-radius: 20px; }
.newtrip > summary {
  list-style: none; cursor: pointer; min-height: 56px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -0.01em;
}
.newtrip > summary::-webkit-details-marker { display: none; }
.newtrip > summary::after { content: '+'; font-family: var(--font-body); font-size: 26px; color: var(--primary); }
.newtrip[open] > summary::after { content: '−'; }
.newtrip .form { padding: 0 20px 20px; }
.empty-hint { color: var(--muted); max-width: 46ch; }

/* Страница поездки */
.back { display: inline-flex; align-items: center; min-height: 44px; gap: 6px; color: var(--muted); text-decoration: none; font-size: 15px; width: fit-content; }
.back:hover { color: var(--ink); }
.trip-top { display: flex; flex-direction: column; gap: 18px; }
.trip-title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.trip-title-row h1 { overflow-wrap: anywhere; }
.stats { display: flex; flex-wrap: wrap; gap: 12px 36px; margin: 0; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat dt { font-size: 14px; color: var(--muted); order: 2; }
.stat dd { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: -0.02em; order: 1; }

.invite {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 14px 16px;
  border: 2px dashed var(--line-strong); border-radius: 18px;
}
.invite-text { flex: 1 1 100%; display: flex; flex-direction: column; }
.invite-text strong { font-weight: 600; }
.invite .input { flex: 1 1 220px; width: auto; min-width: 0; font-size: 15px; }
.invite .btn { flex: 0 0 auto; }

.trip-layout { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.col { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.block { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.person { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; }
.person-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.person-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { display: block; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; width: var(--w, 0%); border-radius: 99px; transform-origin: left center; animation: grow 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.fill-plus { background: var(--plus); }
.fill-minus { background: var(--minus); }
.person-balance { text-align: right; font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: -0.02em; white-space: nowrap; }
.person-balance small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 13px; letter-spacing: 0; color: var(--muted); }
.plus { color: var(--plus); }
.minus { color: var(--minus); }

.legend-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.legend-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.split-list { display: flex; flex-direction: column; gap: 8px; }
.split-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px; align-items: center; gap: 10px; }
.split-row .check { justify-self: start; max-width: 100%; }
.split-row .check:has(input:checked) + .split-input { display: block; }
.split-input { text-align: right; }
.split-input[hidden] { display: none; }
.preview-warn { color: var(--minus); font-weight: 600; }
.preview-ok { color: var(--plus); font-weight: 600; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.form-actions .btn-primary { flex: 1; }
.expense-actions { display: flex; gap: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 12px; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--paper); cursor: pointer; user-select: none;
}
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.check:has(input:checked) { border-color: var(--primary); background: var(--accent-soft); }
.check:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.preview { color: var(--muted); font-size: 15px; min-height: 1.5em; }

.day { display: flex; flex-direction: column; gap: 4px; }
.day + .day { margin-top: 12px; }
.day-title { color: var(--muted); font-weight: 600; font-size: 14px; }
.expense-list { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1.5px solid var(--line); border-radius: 18px; }
.expense { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.expense:first-child { border-top: 0; }
.expense-icon {
  width: 42px; height: 42px; border-radius: 13px; background: var(--accent-soft); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
}
.expense-main { display: flex; flex-direction: column; min-width: 0; }
.expense-title { font-weight: 600; overflow-wrap: anywhere; }
.expense-side { display: flex; flex-direction: column; align-items: flex-end; }
.expense-amount { font-weight: 700; white-space: nowrap; }
.expense-side .btn-link { padding: 0 2px; min-height: 36px; font-size: 14px; color: var(--muted); }
.expense-side .btn-link:hover { color: var(--minus); }
.empty { color: var(--muted); padding: 4px 0; max-width: 40ch; }
.danger-zone { display: flex; justify-content: center; }

.fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 5; min-height: 52px; padding: 0 22px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(13, 27, 62, 0.32);
}

@keyframes grow { from { transform: scaleX(0); } }
@keyframes drop { from { opacity: 0; transform: translateY(-12px) rotate(-1.2deg); } }
.ticket-in { animation: drop 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 90ms); }

@media (min-width: 720px) {
  h1 { font-size: 40px; }
  h2 { font-size: 21px; }
  .hero-title { font-size: 46px; }
  .trip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ticket-sum { font-size: 19px; }
}
@media (min-width: 900px) {
  .topbar { padding: 16px 24px; }
  .page { padding: 12px 24px 72px; gap: 32px; }
  .landing { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 56px; align-items: start; padding-top: 24px; }
  .hero-title { font-size: 54px; }
  .landing-auth { position: sticky; top: 24px; }
  .trip-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 44px; }
  .fab { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bar > i, .ticket-in { animation: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .trip-card { transition: border-color 0.15s, background-color 0.15s, filter 0.15s, transform 0.1s; }
}

[hidden] { display: none !important; }
.tab { padding: 0 4px; font-size: 15px; white-space: nowrap; }
.legend-row .legend { flex: 0 0 auto; }
