/* Berkat Mini App — components, recreated from the hi-fi handoff. */

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}
html,
body {
  margin: 0;
}
body {
  font-family: var(--font);
  color: var(--text);
}

.app {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--app-bg);
  display: flex;
  flex-direction: column;
}

/* Wide viewports (desktop/tablet): the mobile-first column becomes an intentional, elevated app
   rail on a calm branded backdrop — instead of floating in a grey void. All fixed chrome (tab bar,
   main button, help FAB) is already centred on this same 440px column, so it stays aligned. */
@media (min-width: 600px) {
  body {
    background:
      radial-gradient(1100px 680px at 50% -8%, rgba(91, 84, 240, 0.22), transparent 58%),
      linear-gradient(180deg, #e7e9f2, #dcdfe9);
    background-attachment: fixed;
  }
  .app {
    box-shadow: 0 0 0 1px rgba(30, 27, 75, 0.05), 0 24px 70px rgba(30, 27, 75, 0.16);
  }
}

/* ---- screen scaffold ---------------------------------------------------- */
.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
}
/* No per-render entrance animation: screens re-mount on every draw (incl. the
   placeholder→live second render), so animating here caused a double stutter and a
   slide-jump on tab switches. Instant swaps read as snappier and glitch-free. */
/* Reserve room for the fixed bottom button only when a screen actually has one — screens
   that hide it (profile, home, referral, relay) reclaim that space instead of scrolling. */
body.has-mainbtn .screen {
  padding-bottom: 92px;
}
/* While a city list is showing, free vertical room for it: hide the bottom button and
   collapse the *other* route field + the connector line (data-route-field = the active one). */
body.route-editing #mainbtn-slot,
body.route-editing .route-line,
body.route-editing[data-route-field="origin"] .route-row[data-row="destination"],
body.route-editing[data-route-field="destination"] .route-row[data-row="origin"] {
  display: none;
}
.screen__body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.screen-title {
  font: 600 15px var(--font);
  color: var(--text);
  margin-bottom: 10px;
}
.muted {
  color: var(--hint);
}
.reward-text {
  color: var(--reward);
}
/* money figure: amber + display face, for amounts in lists/rows/cards */
.amount {
  font-family: var(--disp);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--reward);
  white-space: nowrap;
}

/* ---- top app bar -------------------------------------------------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
}
.appbar__back {
  font-size: 22px;
  color: var(--accent-text);
  background: none;
  border: 0;
  cursor: pointer;
  line-height: 1;
}
.appbar__title {
  font: 600 16px var(--font);
}

/* gradient mission header (create flow / hero strips) */
.gradbar {
  background: var(--hero);
  color: #fff;
  /* Fill the top safe area (behind the iPhone status bar) with the gradient so the header runs
     edge-to-edge — and, on iOS 26 Safari (which derives the toolbar color from the page content
     instead of the static theme-color meta), the sampled top color is the brand purple. */
  padding: calc(22px + env(safe-area-inset-top, 0px)) 22px 26px;
  /* the signature refonte header: full-bleed gradient, flush to the top, curving in at the
     bottom only ("arrondi vers le bas") */
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
}
.gradbar__label {
  font: 700 11px var(--mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  opacity: 0.85;
}
/* mark + wordmark row at the top of the Missions screen (replaces the old "BERKAT" label) */
.brand-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  display: block;
  border-radius: 9px;
}
.brand-name {
  font: 700 18px var(--font);
  letter-spacing: -0.01em;
  color: #fff;
}
/* Hero slogan: one line in every language. Base 28px; fitHeroTag() shrinks it if a longer
   language would wrap (matches the landing's one-line rule). */
.hero-tag {
  font: 800 28px var(--font);
  letter-spacing: -0.025em;
  line-height: 1.05;
  white-space: nowrap;
}

/* ---- buttons ------------------------------------------------------------ */
.btn {
  display: block;
  width: 100%;
  border: 0;
  cursor: pointer;
  border-radius: var(--r-field);
  padding: 15px;
  text-align: center;
  font: 600 15px var(--font);
  transition:
    transform 0.08s ease,
    filter 0.12s ease;
}
.btn:active {
  transform: scale(0.98);
  filter: brightness(0.97);
}
.btn--primary {
  background: var(--grad);
  color: #fff;
  border-radius: 17px;
  box-shadow: var(--sh-btn);
}
.btn--ghost {
  background: var(--surface-2);
  color: var(--accent-text);
}
.btn--soft {
  background: var(--accent-soft);
  color: var(--accent-text);
}
/* Affirmative secondary — "I'll carry it" = the traveller takes the boarding pass. Uses the
   signature cream ticket paper + ink text, so it stays in the brand's 2-colour palette
   (indigo share / cream pass) instead of adding green; money on it uses --reward-ink (amber
   tuned to read on cream). */
.btn--accept {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--paper-2);
}
.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* fixed bottom "MainButton" fallback (when not inside Telegram) */
.mainbtn {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 14px;
  width: min(404px, calc(100vw - 36px));
  z-index: 20;
}

/* ---- cards & tiles ------------------------------------------------------ */
.card {
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--sh-card);
  border: 1px solid var(--border);
}
.card--pad {
  padding: 15px;
}
.row {
  display: flex;
  align-items: center;
  gap: 11px;
}
.hatch {
  background: var(--hatch);
}
.thumb {
  width: 50px;
  height: 50px;
  border-radius: var(--r-tile);
  flex: 0 0 auto;
}
.label-caps {
  font: 700 11px var(--mono);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--hint);
}

/* ---- the ticket motif (signature) -------------------------------------- */
.ticket {
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--sh-hero);
  background: var(--paper);
  color: var(--ink);
}
/* boarding-pass data labels sit muted on the cream paper, not on --hint (a dark-surface token) */
.ticket .label-caps,
.sharecard .label-caps {
  color: var(--ink-2);
}
.ticket__top {
  background: var(--grad-mission);
  color: #fff;
  padding: 15px 17px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.ticket__big {
  font: 800 40px var(--disp);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-top: 4px;
}
.ticket__mid {
  background: var(--paper);
  padding: 14px 17px 16px;
}
/* perforation line with two notches punched out of the card sides */
.perf {
  position: relative;
  height: 0;
  margin: 14px 0 13px;
  border-top: 1.5px dashed var(--paper-line);
}
.perf::before,
.perf::after {
  content: "";
  position: absolute;
  top: -11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--notch);
}
.perf::before {
  left: -28px;
}
.perf::after {
  right: -28px;
}
.stubs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.stub {
  border: 1.5px solid var(--paper-line);
  border-radius: var(--r-tile);
  padding: 10px 11px;
}
.stub--accent {
  border-color: rgba(91, 84, 240, 0.4);
  background: rgba(91, 84, 240, 0.08);
}
.stub__num {
  font: 800 20px var(--disp);
  letter-spacing: -0.015em;
  /* stub figures are money here (wallet balances, share-card rewards) → amber, tuned to
     read on cream. Profile reuses .stub for reputation stats and overrides this to ink. */
  color: var(--reward-ink);
  margin-top: 3px;
}
.stub--accent .label-caps {
  color: var(--brand);
}

/* ---- share card (300px viral object) ----------------------------------- */
.sharecard {
  width: 300px;
  max-width: 100%;
  border-radius: var(--r-card);
  border-bottom-left-radius: 6px;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
}
.sharecard__top {
  background: var(--grad-mission);
  color: #fff;
  padding: 13px 15px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.sharecard__route {
  display: flex;
  flex-direction: column;
  font: 700 19px var(--font);
  line-height: 1.15;
  margin-top: 4px;
}
.sharecard__pot {
  font: 800 26px var(--disp);
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}

/* ---- segmented control -------------------------------------------------- */
.segmented {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-field);
  padding: 4px;
  gap: 4px;
}
.segmented__opt {
  flex: 1;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 10px;
  padding: 10px 8px;
  font: 600 13px var(--font);
  color: var(--text-2);
}
.segmented__opt[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--sh-card);
}
/* the selected tab's count is a purple chip in the refonte (the inactive one stays neutral) */
.segmented__opt[aria-selected="true"] .count {
  background: var(--brand-soft);
  color: var(--brand-2);
}
/* small count badge inside a segmented tab option (e.g. "Active 3") */
.segmented__opt .count {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  margin-left: 4px;
  font: 700 11px var(--font);
  line-height: 18px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--hint);
  vertical-align: 1px;
}
.segmented__opt[aria-selected="true"] .count {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* the profile is the one screen allowed to scroll (it's exempt from the at-a-glance vertical
   guard), so it matches the refonte at full size instead of being compacted to fit */
.screen__body.profile {
  gap: 13px;
}
.screen__body.profile .ticket__top {
  padding: 18px 20px;
}
.screen__body.profile .stub__num {
  font-size: 22px;
  color: var(--ink); /* reputation stats are not money — neutral ink on the paper pass */
}
.screen__body.profile .icon-box--sm {
  width: 38px;
  height: 38px;
  border-radius: 11px;
}

/* language picker: a wrapping 3-column grid so all 6 locales fit the phone width */
.langs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.langs .segmented__opt {
  background: var(--surface-2);
  border-radius: 12px;
}
.langs .segmented__opt[aria-selected="true"] {
  background: var(--surface);
  box-shadow: var(--sh-card);
}

/* ---- chips -------------------------------------------------------------- */
.chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.chip {
  background: var(--surface);
  border: 1.5px solid var(--border-accent);
  color: var(--accent-text);
  border-radius: var(--r-pill);
  padding: 9px 15px;
  font: 600 13px var(--font);
  cursor: pointer;
}
.chip[aria-pressed="true"] {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ---- inputs ------------------------------------------------------------- */
.field {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-field);
  padding: 13px 14px;
  /* 16px min: a smaller font makes iOS Safari zoom the page when the field is focused. This class
     backs most form inputs (route, offer, residence, relay/ticket messages, description, help). */
  font: 400 16px var(--font);
  color: var(--text);
}
.field::placeholder {
  color: var(--hint);
}
/* prominent first-thing input (the item to carry) — stands out from the surface */
.field--hero {
  background: var(--surface);
  border: 1.5px solid var(--border-accent);
  font: 600 16px var(--font);
  padding: 15px 16px;
  box-shadow: var(--sh-card);
}
.field--hero::placeholder {
  color: var(--hint);
  font-weight: 500;
}

/* keep a little breathing room when a route field is scrolled to the top under the keyboard */
#f-origin,
#f-destination {
  scroll-margin-top: 14px;
}

/* city autocomplete suggestions (route step) */
.suggest {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.suggest__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-field);
  padding: 11px 14px;
  cursor: pointer;
}
.suggest__item:active {
  background: var(--surface-2);
}
.suggest__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.suggest__name {
  font: 600 14px var(--font);
  color: var(--text);
}
.suggest__region {
  font: 400 12px var(--font);
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* the 2-letter country code, made prominent so same-named cities are easy to tell apart */
.suggest__cc {
  flex: none;
  font: 800 12px var(--font);
  letter-spacing: 0.04em;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--border-accent);
  border-radius: 8px;
  padding: 4px 8px;
}

/* photo slots */
.photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.photo {
  aspect-ratio: 1;
  border-radius: var(--r-tile);
}
.photo-del {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font: 600 17px/1 var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo--add {
  border: 1.5px dashed var(--border-accent);
  background: var(--accent-soft);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 12px var(--font);
  cursor: pointer;
}

/* ---- pot split bars ----------------------------------------------------- */
.split {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.split__row {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 500 13px var(--font);
}
.split__bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.split__fill {
  height: 100%;
  border-radius: 4px;
}
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border-radius: var(--r-field);
  padding: 8px 10px;
}
.stepper__btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 0;
  background: var(--surface);
  box-shadow: var(--sh-card);
  font-size: 20px;
  cursor: pointer;
  color: var(--accent-text);
}
.stepper__val {
  font: 800 22px var(--disp);
}

/* ---- PIN cells ---------------------------------------------------------- */
.pin {
  display: flex;
  gap: 9px;
}
.pin__cell {
  flex: 1;
  aspect-ratio: 1;
  max-width: 56px;
  border-radius: var(--r-tile);
  background: rgba(255, 255, 255, 0.14);
  border: 1.5px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 24px var(--mono);
  color: #fff;
}
.pin__cell--active {
  border-color: #fff;
}

/* ---- badges / member pass ---------------------------------------------- */
.badges {
  display: flex;
  gap: 7px;
}
/* a kudos badge: the icon tile + a small count chip when received more than once */
.badge-chip {
  position: relative;
  cursor: pointer;
}
.badge-chip__n {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font: 700 10px/16px var(--font);
  text-align: center;
}
.badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.avatar {
  border-radius: 50%;
  background: var(--grad-avatar);
  flex: 0 0 auto;
}

/* ---- progress segments -------------------------------------------------- */
.progress {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}
.progress__seg {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
}
.progress__seg--on {
  background: #fff;
}

/* create wizard: a FLAT step header (the design has no gradient here) — muted caps label +
   box icon, with a thin segmented bar that fills with brand as steps complete. */
.stephead {
  padding: 18px 16px 0;
}
.stephead__label {
  font: 700 12px var(--font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.stephead__icon {
  color: var(--text-2);
  display: flex;
  flex: none;
}
.stepbar {
  display: flex;
  gap: 6px;
  margin-top: 11px;
}
.stepbar__seg {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border-2);
}
.stepbar__seg--on {
  background: var(--brand);
}

/* field labels in the create wizard (design: 13px, text-2, sentence case) */
.field-label {
  font: 600 13px var(--font);
  color: var(--text-2);
}
/* a row of separate selectable tiles (weight, etc.) — the design's look, not a joined segment */
.pills {
  display: flex;
  gap: 10px;
}
.pill {
  flex: 1;
  height: 48px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font: 600 15px var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pill[aria-selected="true"] {
  background: var(--surface-2);
  border: 1.5px solid var(--brand);
  color: var(--text);
  font-weight: 700;
}

/* ---- chat bubbles (relay) ---------------------------------------------- */
.chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
}
.bubble {
  max-width: 80%;
  padding: 10px 13px;
  font: 400 13.5px/1.45 var(--font);
  border-radius: var(--r-bubble);
}
.bubble--in {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text);
  border-bottom-left-radius: 5px;
  box-shadow: var(--sh-card);
}
.bubble--out {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 6px rgba(91, 84, 240, 0.28);
}
.bubble__text {
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- chat layout: composer pinned to the bottom, messages scroll between ---- */
.screen.relay {
  height: 100dvh;
  overflow: hidden; /* the chat scrolls internally, the screen itself doesn't */
}
.relay__banner {
  padding: 12px 18px 2px;
}
.relay .chat {
  flex: 1;
  min-height: 0; /* lets the flex child actually scroll instead of growing the screen */
  overflow-y: auto;
}
.relay .composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--app-bg);
}
.relay .composer .field {
  flex: 1;
}
.relay .composer__send {
  width: 48px;
  min-width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(91, 84, 240, 0.36);
}
.relay .composer__note {
  font: 400 11px var(--font);
}

/* read-receipt ticks on outgoing bubbles: single check = sent, double blue = read */
.tick {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  vertical-align: -3px;
}
.tick svg {
  width: 15px;
  height: 15px;
}
.tick--pending {
  color: rgba(255, 255, 255, 0.45);
}
.tick--sent {
  color: rgba(255, 255, 255, 0.72);
}
.tick--delivered {
  color: rgba(255, 255, 255, 0.72);
}
.tick--read {
  color: #8fe0ff;
}
.tick--failed {
  color: #ffd0d0;
}
/* a message whose POST failed — dimmed + tappable to retry */
.bubble--failed {
  opacity: 0.7;
  cursor: pointer;
}
.banner--warn {
  margin: 0 14px;
  border-color: #e0a;
  color: #c0392b;
}
.banner {
  background: var(--accent-soft);
  border: 1.5px solid var(--border-accent);
  color: var(--accent-text);
  border-radius: 13px;
  padding: 11px 13px;
  font: 600 12.5px var(--font);
}

/* ---- referral chain ----------------------------------------------------- */
.chain {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.chain__node {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.chain__node--porter {
  border-color: var(--border-accent);
  background: var(--accent-soft);
}
.chain__link {
  width: 2px;
  height: 16px;
  background: var(--border-accent);
  margin-left: 30px;
}

/* ---- home launcher ------------------------------------------------------ */
.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: inherit;
}
.tile__icon {
  font-size: 24px;
}
.tile__name {
  font: 600 14px var(--font);
}
.tile__sub {
  font: 400 11px var(--font);
  color: var(--hint);
}

/* ======================================================================== */
/*  Modern shell: Lucide icons, bottom tab bar, list rows, status, timeline */
/* ======================================================================== */

/* inline Lucide icon — inherits text color, sits on the text baseline */
.ico {
  display: inline-block;
  vertical-align: -0.18em;
  flex: 0 0 auto;
}

/* rounded "icon chip" — replaces the old emoji badges/tiles */
.icon-box {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.icon-box--brand {
  background: var(--brand);
  color: #fff;
}
.icon-box--reward {
  background: rgba(24, 178, 107, 0.12);
  color: var(--reward);
}
.icon-box--muted {
  background: var(--surface-2);
  color: var(--text-2);
}
.icon-box--sm {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}
/* a not-yet-earned badge: dimmed + desaturated, but still tappable to learn the criterion */
.icon-box--locked {
  opacity: 0.38;
  filter: grayscale(0.6);
}

/* ---- bottom tab bar ----------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar[hidden] {
  display: none;
}
.tabbar__item {
  flex: 1;
  border: 0;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 7px;
  color: var(--hint);
  transition: color 0.12s ease;
}
.tabbar__item span {
  font: 600 10.5px var(--font);
  letter-spacing: 0.01em;
}
.tabbar__item[aria-current="page"] {
  color: var(--brand);
}
.tabbar__item:active {
  filter: brightness(0.9);
}
/* keep tab content clear of the fixed bar (the bar itself is ~56px tall) */
body.has-tabbar .screen {
  padding-bottom: 62px;
}

/* ---- list rows (tappable, icon + label + chevron) ----------------------- */
.list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--sh-card);
  overflow: hidden;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  padding: 13px 14px;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.list-row:first-child {
  border-top: 0;
}
.list-row:active {
  background: var(--surface-2);
}
.list-row__body {
  flex: 1;
  min-width: 0;
}
.list-row__title {
  font: 600 14px var(--font);
  color: var(--text);
}
.list-row__sub {
  font: 400 12px var(--font);
  color: var(--hint);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row__chev {
  color: var(--hint);
}

/* a section title with optional trailing action */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 2px 0;
}
.section-head .label-caps {
  letter-spacing: 0.08em;
}

/* ---- status pill -------------------------------------------------------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 700 10px var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px 3px 7px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
}
.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status--active {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.status--waiting {
  background: rgba(214, 138, 4, 0.12);
  color: #b8780a;
}
.status--done {
  background: rgba(24, 178, 107, 0.12);
  color: var(--success);
}
.status--dead {
  background: var(--surface-2);
  color: var(--hint);
}
/* unread relay messages — a filled brand pill with the message icon + count */
.status--unread {
  background: var(--brand);
  color: #fff;
}
.status--unread::before {
  display: none;
}
.status--unread svg {
  width: 11px;
  height: 11px;
}

/* count badge on a list-row (e.g. the Messages action in the mission detail) */
.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font: 700 11px var(--font);
  margin-right: 2px;
}

/* accent dot on a mission's icon when it has unread messages */
.icon-box--dot {
  position: relative;
}
.icon-box--dot::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
}

/* ---- mission-detail timeline (light surface) ---------------------------- */
.timeline {
  display: flex;
  gap: 5px;
}
.timeline__seg {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
}
.timeline__seg--on {
  background: var(--brand);
}
.timeline__seg--done {
  background: var(--reward);
}

/* ---- labeled milestone stepper (clear done / current / upcoming) -------- */
/* refonte: reassurance box (escrow promise) + the collapsed "All N steps" accordion */
.reassure {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--brand-soft);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--brand-2);
}
.reassure span {
  font: 500 13px var(--font);
  line-height: 1.4;
}
.steps-acc {
  margin-top: 13px;
  border-top: 1px solid var(--border);
}
.steps-acc summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-2);
  font: 600 13px var(--font);
}
.steps-acc summary::-webkit-details-marker {
  display: none;
}
.steps-acc summary::after {
  content: "▾";
  font-size: 11px;
}
.steps-acc[open] summary::after {
  content: "▴";
}
.steps-acc .steps {
  margin-top: 8px;
}
/* generic card-level accordion (e.g. the delivered-mission proof) */
.acc > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font: 700 15px var(--font);
}
.acc > summary::-webkit-details-marker {
  display: none;
}
.acc > summary::after {
  content: "▾";
  color: var(--text-3);
  font-size: 12px;
}
.acc[open] > summary::after {
  content: "▴";
}
/* proof gallery: a row of selectable photos driving one shared map + caption */
.proof-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.proof-row::-webkit-scrollbar {
  display: none;
}
.proof-thumb {
  flex: none;
  width: 66px;
  height: 66px;
  border-radius: 13px;
  border: 2px solid transparent;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-2);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s ease;
}
.proof-thumb--active {
  border-color: var(--brand);
}
.proof-map {
  width: 100%;
  display: block;
  border-radius: 14px;
  margin-top: 12px;
  border: 1px solid var(--border);
}
.proof-cap {
  font: 500 12px var(--font);
  color: var(--text-2);
  margin-top: 8px;
  line-height: 1.4;
}

.steps {
  display: flex;
  flex-direction: column;
}
.step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 5px 0;
}
.step__dot {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--hint);
  z-index: 1;
}
/* connector line between dots */
.step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 22px;
  bottom: -5px;
  width: 2px;
  background: var(--border);
}
.step__label {
  font: 500 13.5px var(--font);
  color: var(--hint);
}
.step--done .step__dot {
  background: #2fb84d;
  border-color: #2fb84d;
  color: #fff;
}
.step--done:not(:last-child)::before {
  background: #2fb84d;
}
.step--done .step__label {
  color: var(--text);
}
.step--now .step__dot {
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}
.step--now .step__dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}
.step--now .step__label {
  color: var(--text);
  font-weight: 600;
}

/* ---- proof-of-handoff (role+state driven) ------------------------------ */
.handoff-steps {
  margin-bottom: 4px;
}
.handoff-steps__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font: 600 10px var(--font);
  letter-spacing: 0.04em;
  color: var(--hint);
  text-transform: uppercase;
}
.handoff-steps__labels span {
  flex: 1;
  text-align: center;
}
.handoff-steps__labels span:first-child {
  text-align: left;
}
.handoff-steps__labels span:last-child {
  text-align: right;
}
/* the big "your turn / waiting" status card */
.handoff-status {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 15px;
  border-radius: var(--r-card);
  border: 1px solid var(--border);
  background: var(--surface);
}
.handoff-status__icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.handoff-status__title {
  font: 700 16px var(--font);
}
.handoff-status__sub {
  font: 400 13px var(--font);
  color: var(--hint);
  margin-top: 3px;
  line-height: 1.35;
}
/* tone: act = it's your move (accent) · wait = on the other party (neutral) ·
   done = settled (success green) · dead = closed/disputed (muted red) */
.handoff-status--act {
  border-color: var(--border-accent);
  background: var(--accent-soft);
}
.handoff-status--act .handoff-status__icon {
  background: var(--brand);
  color: #fff;
}
.handoff-status--wait .handoff-status__icon {
  background: var(--surface-2);
  color: var(--hint);
}
.handoff-status--done {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
}
.handoff-status--done .handoff-status__icon {
  background: var(--success);
  color: #fff;
}
.handoff-status--dead .handoff-status__icon {
  background: var(--surface-2);
  color: #c0392b;
}

/* primary action with a leading icon */
.btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* big avatar/hero icon */
.icon-box--lg {
  width: 56px;
  height: 56px;
  border-radius: 16px;
}

/* Tiny "re-roll my pseudonym" button next to the profile name. Subtle by design —
   it's a one-shot, not a flashy action; the shuffle icon is the only affordance. */
.pseudo-reroll {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease;
  flex-shrink: 0;
}
.pseudo-reroll:hover {
  background: rgba(255, 255, 255, 0.28);
}
.pseudo-reroll:active {
  transform: scale(0.94);
}

/* Escrow reassurance — short trust signal on the mission detail card. Soft accent
   so it reads as informational, not a warning. */
.escrow-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: 10px;
  font: 500 12.5px var(--font);
  line-height: 1.25;
}
.escrow-note svg {
  flex-shrink: 0;
}

/* ---- support: floating help button + category chips --------------------- */
#help-fab {
  position: fixed;
  /* Hug the app column's right edge (half of the 440px column = 220px, minus a 16px inset) on
     wide screens; stays a plain 16px from the edge on mobile where the column fills the viewport. */
  right: max(16px, calc(50% - 204px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 74px);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  font: 700 19px var(--font);
  cursor: pointer;
  z-index: 40;
  opacity: 0.92;
}
#help-fab:active { transform: scale(0.94); }
.chip--on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* --- Web/PWA phone-OTP login overlay (never shown in Telegram) -------------- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 28px 22px 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 800 22px var(--font);
  color: var(--brand);
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}
.login-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: block;
  flex: none;
}
.login-title {
  font: 800 24px var(--font);
  color: var(--text);
  margin: 0 0 6px;
}
.login-sub {
  font: 400 15px var(--font);
  color: var(--text-2);
  margin: 0 0 18px;
  line-height: 1.4;
}
.login-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--r-field);
  padding: 14px;
  font: 500 16px var(--font);
  margin-bottom: 12px;
}
.login-input:focus {
  outline: none;
  border-color: var(--brand);
}
.login-code-input {
  letter-spacing: 0.4em;
  text-align: center;
  font: 700 20px var(--font);
}
.login-btn {
  margin-top: 6px;
}
.login-link {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  color: var(--text-2);
  font: 500 14px var(--font);
  padding: 14px 0 2px;
  cursor: pointer;
}
.login-error {
  color: #e5484d;
  font: 500 14px var(--font);
  margin: 2px 0 10px;
}
/* intl-tel-input theming: make the vendored widget read as our field. */
.login-card .iti { width: 100%; }
.login-card .iti__tel-input,
.login-card .iti input[type="tel"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--r-field);
  padding: 14px;
  font: 500 16px var(--font);
  margin-bottom: 12px;
}
.login-card .iti__tel-input:focus,
.login-card .iti input[type="tel"]:focus {
  outline: none;
  border-color: var(--brand);
}
/* NOTE: unscoped from .login-card on purpose. On narrow screens intl-tel-input switches to
   iti--fullscreen-popup and reparents the dropdown to <body> (outside .login-card), so any
   .login-card-scoped rule silently stops applying. iti is only used on the login screen, so
   targeting .iti__ directly is safe and works in both inline and popup modes. */
.iti__dropdown-content {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--r-field);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.16);
  overflow: hidden;
  margin-top: 6px;
}
/* The country search: style the WRAPPER as one inset field so the loupe sits INSIDE the
   frame (it's a flex sibling of the input, not a background glyph — margin on the input alone
   would leave it hanging off the left edge). */
.iti__search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px;
  padding: 0 12px;
  height: 44px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-tile);
  background: var(--surface-2);
}
.iti__search-input-wrapper:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.iti__search-icon { display: flex; flex: none; }
.iti__search-icon-svg { stroke: var(--text-3); }
.iti__search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  margin: 0;
  /* left padding clears the absolutely-positioned loupe (else it overlaps the placeholder). */
  padding: 0 0 0 26px;
  border: 0;
  background: transparent;
  color: var(--text);
  /* >=16px: a smaller font makes iOS Safari zoom the page when the search auto-focuses on open. */
  font: 500 16px var(--font);
}
.iti__search-input:focus { outline: none; box-shadow: none; }
.iti__search-input::placeholder { color: var(--text-3); }
/* Full-bleed list under the inset search: hairline separator + a touch more left gutter so
   the flags aren't jammed against the edge. */
.iti__search-input-wrapper + .iti__country-list { border-top: 1px solid var(--border); }
.iti__country { padding-left: 16px; }
.iti__country-list { max-height: 260px; }
