/* М731 (GROUP_CHAT_INBOX): чат группы отдельным диалогом — строка в «Сообщениях», экран чата, список участников.
   Цвета — токены widget.css (тёмная/светлая/оболочка мессенджера сами); свои переменные — только тон аватаров. */
:root { --sgi-bs: 38%; --sgi-bl: 25%; --sgi-fs: 86%; --sgi-fl: 84%; --sgi-veil: rgba(3, 9, 14, .62); }
:root[data-theme="light"] { --sgi-bs: 64%; --sgi-bl: 90%; --sgi-fs: 60%; --sgi-fl: 29%; --sgi-veil: rgba(19, 40, 58, .38); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not(.inapp) { --sgi-bs: 64%; --sgi-bl: 90%; --sgi-fs: 60%; --sgi-fl: 29%; --sgi-veil: rgba(19, 40, 58, .38); }
}
:root.inapp-light { --sgi-bs: 64%; --sgi-bl: 90%; --sgi-fs: 60%; --sgi-fl: 29%; --sgi-veil: rgba(19, 40, 58, .38); }
.sgi-c0 { --sgi-h: 208; } .sgi-c1 { --sgi-h: 262; } .sgi-c2 { --sgi-h: 158; }
.sgi-c3 { --sgi-h: 36; } .sgi-c4 { --sgi-h: 328; } .sgi-c5 { --sgi-h: 188; }
.sgi-hide { display: none !important; }
html.sgi-open, html.sgi-open body { overflow: hidden; }

/* ---------- строка группы в списке «Сообщения» ---------- */
.sgi-own { margin: 0 0 8px; }
.sgi-row .me-av.sgi-gav, .m222 .m222-row .me-av.sgi-gav, .sgi-gav {
  position: relative; border-radius: 14px; border: 0; color: var(--ink); font-weight: 750; letter-spacing: .01em;
  background: linear-gradient(140deg, var(--coral2), var(--coral)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); }
.sgi-row .tc-main small { color: var(--muted); }
.sgi-go { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin-top: 8px; }

/* ---------- аватары в готовых экранах: фото тренера, знак AirFit; последние сообщения не уходят под поле ввода ---------- */
.me-av.sgi-ph, .m222-avatar.sgi-ph { position: relative; overflow: hidden; }
.sgi-ph-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; border-radius: inherit; }
.me-av.sgi-af, .m222 .m222-row .me-av.sgi-af, .sgi-pav.sgi-af { border: 0; background: linear-gradient(140deg, var(--coral2), var(--coral)); color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); }
.sgi-mark-svg { width: 58%; height: 58%; display: block; }
.sgi-th-head { justify-content: flex-start; flex-wrap: nowrap; }
.sgi-th-head h1 { min-width: 0; overflow-wrap: anywhere; }
.tc-msgs > li.tc-b.their.sgi-av { position: relative; margin-left: 40px; max-width: min(calc(86% - 40px), 520px); }
.tc-msgs > li.tc-b.their.sgi-av > .sgi-pav { position: absolute; left: -40px; top: 0; }
.tc-msgs > li { scroll-margin-bottom: calc(var(--tabbar, 64px) + 190px); }

/* ---------- экран чата ---------- */
.sgi-screen { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 400 16px/1.45 var(--f-body, system-ui, sans-serif); animation: sgi-in .18s ease-out; }
@keyframes sgi-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.sgi-screen:focus { outline: none; }
.sgi-top { display: flex; align-items: center; gap: 2px; padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px 4px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.sgi-back, .sgi-x { flex: 0 0 44px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: none; color: var(--text); cursor: pointer; }
.sgi-back svg, .sgi-x svg { width: 22px; height: 22px; }
.sgi-back:hover, .sgi-x:hover { background: var(--raise); }
.sgi-info { flex: 1 1 auto; min-width: 0; min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 6px;
  border: 0; border-radius: 14px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.sgi-info:hover { background: var(--raise); }
.sgi-info > svg { flex: 0 0 16px; width: 16px; height: 16px; color: var(--muted); }
.sgi-gav-top { flex: 0 0 40px; width: 40px; height: 40px; display: grid; place-items: center; font-size: 14px; }
.sgi-tt { flex: 1 1 auto; min-width: 0; display: grid; }
.sgi-tt b { font: 650 16px/1.25 var(--f-head, inherit); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sgi-tt small { color: var(--muted); font-size: 12px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sgi-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 12px 12px 8px; }
.sgi-top, .sgi-scroll > *, .sgi-foot > * { box-sizing: border-box; }
.sgi-scroll > *, .sgi-foot > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.sgi-legal { margin-top: 0; margin-bottom: 4px; max-width: 460px; padding: 9px 13px; border-radius: 14px; background: var(--raise); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; overflow-wrap: anywhere; }
.sgi-state { margin-top: 28px; margin-bottom: 0; text-align: center; color: var(--muted); font-size: 14px; }
.sgi-msgs { list-style: none; padding: 0; margin-top: 0; margin-bottom: 0; display: flex; flex-direction: column; gap: 3px; }
.sgi-day { align-self: center; margin: 12px 0 2px; }
.sgi-day span { display: inline-block; padding: 3px 11px; border-radius: 999px; background: var(--raise2); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.sgi-empty { align-self: center; display: grid; gap: 4px; margin: 34px 0; text-align: center; color: var(--muted); font-size: 13px; max-width: 280px; }
.sgi-empty b { color: var(--text); font-size: 16px; }
.sgi-m { display: flex; align-items: flex-start; gap: 8px; max-width: min(88%, 560px); min-width: 0; }
.sgi-m.sgi-first { margin-top: 10px; }
.sgi-their { align-self: flex-start; }
.sgi-mine { align-self: flex-end; }
.sgi-col { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.sgi-mine .sgi-col { align-items: flex-end; }
.sgi-pav { position: relative; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  font-size: 12px; font-weight: 750; letter-spacing: .01em; line-height: 1;
  background: hsl(var(--sgi-h, 208), var(--sgi-bs), var(--sgi-bl)); color: hsl(var(--sgi-h, 208), var(--sgi-fs), var(--sgi-fl)); }
.sgi-pav img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.sgi-pav-tr { background: var(--coral); color: var(--ink); }
.sgi-pav-anon { background: var(--raise2); color: var(--muted); }
.sgi-pav-anon::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; opacity: .65;
  box-shadow: 0 10px 0 -1px currentColor; transform: translateY(-4px); }
.sgi-pav-lg { flex-basis: 42px; width: 42px; height: 42px; font-size: 14px; }
.sgi-pav-gap { flex: 0 0 32px; width: 32px; }
.sgi-who { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 6px; padding: 0 4px; font-size: 12.5px; line-height: 1.3; min-width: 0; }
.sgi-who b { font-weight: 650; color: hsl(var(--sgi-h, 208), var(--sgi-fs), var(--sgi-fl)); overflow-wrap: anywhere; }
.sgi-who b.sgi-cx { color: var(--text2); }
.sgi-r-trainer .sgi-who b { color: var(--coral); }
.sgi-tag { flex: 0 0 auto; padding: 1px 7px; border-radius: 999px; background: var(--soft); border: 1px solid var(--soft-line); color: var(--coral);
  font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; line-height: 1.5; }
.sgi-tag-af { background: var(--raise2); border-color: var(--line2); color: var(--muted); }
.sgi-bub { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 0 10px; min-width: 0; max-width: 100%;
  padding: 8px 12px 6px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); color: var(--text); overflow-wrap: anywhere; }
.sgi-bub p { flex: 1 1 auto; min-width: 0; margin: 0; white-space: pre-wrap; font-size: 15px; line-height: 1.4; }
.sgi-bub time { flex: 0 0 auto; margin-left: auto; font-size: 10.5px; line-height: 1.6; color: var(--muted); font-variant-numeric: tabular-nums; }
.sgi-their.sgi-first .sgi-bub { border-top-left-radius: 6px; }
.sgi-r-trainer.sgi-their .sgi-bub { border-color: var(--soft-line); background: linear-gradient(0deg, var(--soft), var(--soft)), var(--panel); }
.sgi-mine .sgi-bub { background: var(--coral); border-color: transparent; color: var(--ink); cursor: pointer; }
.sgi-mine.sgi-first .sgi-bub { border-top-right-radius: 6px; }
.sgi-mine .sgi-bub time { color: inherit; opacity: .72; }
.sgi-mine .sgi-bub.sgi-gone { background: var(--raise2); color: var(--muted); cursor: default; }
.sgi-gone p { font-style: italic; opacity: .8; }
.sgi-del { min-height: 32px; padding: 4px 6px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12.5px; text-decoration: underline; cursor: pointer; }
.sgi-foot { padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); background: var(--panel); border-top: 1px solid var(--line); }
.sgi-composer { display: flex; align-items: flex-end; gap: 8px; }
.sgi-composer[hidden], .sgi-note[hidden], .sgi-err[hidden], .sgi-legal[hidden], .sgi-state[hidden], .sgi-del[hidden] { display: none; }
.sgi-input { flex: 1 1 auto; min-width: 0; min-height: 44px; max-height: 132px; resize: none; box-sizing: border-box; padding: 10px 15px; border: 1px solid var(--line2);
  border-radius: 22px; background: var(--field); color: var(--text); font: inherit; font-size: 16px; line-height: 1.35; }
.sgi-input::placeholder { color: var(--muted); }
.sgi-send { flex: 0 0 44px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--coral); color: var(--ink);
  cursor: pointer; transition: transform .12s, opacity .12s; }
.sgi-send svg { width: 22px; height: 22px; }
.sgi-send:disabled { opacity: .38; cursor: default; }
.sgi-send:not(:disabled):active { transform: scale(.94); }
.sgi-note { margin-top: 6px; margin-bottom: 0; padding: 0 6px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.sgi-err { margin-top: 0; margin-bottom: 6px; padding: 0 6px; color: var(--coral); font-size: 13px; }

/* ---------- «Ближайшее занятие»: кто едет (статус — цветом кольца у аватара и подписи) ---------- */
.sgi-next { background: var(--panel); border-bottom: 1px solid var(--line); }
.sgi-next[hidden] { display: none; }
.sgi-next > * { box-sizing: border-box; max-width: 720px; margin-left: auto; margin-right: auto; }
.sgi-next-h { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 6px 12px; border: 0; background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer; }
.sgi-next-h > svg { flex: 0 0 16px; width: 16px; height: 16px; color: var(--muted); }
.sgi-next-ic { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--soft); color: var(--coral); }
.sgi-next-ic svg { width: 18px; height: 18px; }
.sgi-next-t { flex: 1 1 auto; min-width: 0; display: grid; }
.sgi-next-t small { color: var(--muted); font-size: 11px; line-height: 1.3; letter-spacing: .02em; }
.sgi-next-t b { font-size: 14.5px; font-weight: 650; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sgi-next-sum { flex: 0 0 auto; padding: 2px 9px; border-radius: 999px; background: var(--raise2); color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.sgi-next-sum-ok { background: var(--ok-soft); color: var(--ok); }
.sgi-stack { flex: 0 0 auto; display: inline-flex; padding-left: 6px; }
.sgi-stack .sgi-pav { flex-basis: 24px; width: 24px; height: 24px; margin-left: -6px; font-size: 9.5px; }
.sgi-stack .sgi-pav { outline: 0; opacity: 1; }
.sgi-next:not(.sgi-next-open) .sgi-next-ic { display: none; }
.sgi-next-b { padding: 0 12px 12px; max-height: 46vh; overflow-y: auto; }
.sgi-next-tabs { display: flex; gap: 6px; margin: 0 0 8px; overflow-x: auto; }
.sgi-next-tab { flex: 0 0 auto; min-height: 36px; padding: 0 12px; border: 1px solid var(--line2); border-radius: 999px; background: none; color: var(--text2);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.sgi-next-tab[aria-pressed="true"] { border-color: var(--soft-line); background: var(--soft); color: var(--coral); }
.sgi-next-sub { margin: 0 0 8px; color: var(--muted); font-size: 12.5px; }
.sgi-ros { list-style: none; margin: 0; padding: 2px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.sgi-ro { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sgi-ro-t { min-width: 0; display: grid; }
.sgi-ro-t b { font-size: 13.5px; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sgi-ro-t small { font-size: 11.5px; line-height: 1.3; color: var(--muted); }
.sgi-ro-me .sgi-ro-t b { font-weight: 750; }
/* едет — зелёный, лист ожидания — жёлтый, не сможет — серый, не ответил — контур */
.sgi-s-going.sgi-pav, .sgi-s-confirmed.sgi-pav, .sgi-s-going .sgi-pav, .sgi-s-confirmed .sgi-pav, .sg-going .sg-av, .sg-confirmed .sg-av {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--ok); }
.sgi-s-waitlist.sgi-pav, .sgi-s-waiting.sgi-pav, .sgi-s-waitlist .sgi-pav, .sgi-s-waiting .sgi-pav, .sg-waitlist .sg-av, .sg-waiting .sg-av {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--amber); }
.sgi-s-declined.sgi-pav, .sgi-s-declined .sgi-pav, .sg-declined .sg-av { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--line2); opacity: .6; }
.sgi-s-no_answer.sgi-pav, .sgi-s-not_booked.sgi-pav, .sgi-s-no_answer .sgi-pav, .sgi-s-not_booked .sgi-pav, .sg-no_answer .sg-av, .sg-not_booked .sg-av {
  outline: 2px dashed var(--ctl); outline-offset: 2px; }
.sgi-s-going .sgi-ro-t small, .sgi-s-confirmed .sgi-ro-t small { color: var(--ok); font-weight: 650; }
.sgi-s-waitlist .sgi-ro-t small, .sgi-s-waiting .sgi-ro-t small { color: var(--amber); font-weight: 650; }
.sgi-s-declined .sgi-ro-t b { color: var(--muted); }
.sg-list .sg-p { padding-left: 4px; }
.sgi-next-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.sgi-nb { flex: 1 1 0; min-width: 120px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line2); border-radius: 14px; background: none; color: var(--text);
  font: inherit; font-weight: 650; cursor: pointer; }
.sgi-nb-yes { border-color: transparent; background: var(--coral); color: var(--ink); }
.sgi-nb:disabled { opacity: .5; cursor: default; }
.sgi-mark { flex: 1 1 0; min-width: 120px; display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 650; color: var(--text2); }
.sgi-mark::before { content: ""; flex: 0 0 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--line2); }
.sgi-mark-ok { color: var(--ok); } .sgi-mark-ok::before { background: var(--ok); }
.sgi-mark-wl { color: var(--amber); } .sgi-mark-wl::before { background: var(--amber); }
.sgi-next-msg { margin: 8px 0 0; color: var(--text2); font-size: 13px; }

/* ---------- участники ---------- */
.sgi-sheet-back { position: absolute; inset: 0; z-index: 1; background: var(--sgi-veil); }
.sgi-sheet { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; max-height: 82%; overflow-y: auto; box-sizing: border-box; max-width: 720px; margin: 0 auto;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px)); border-radius: 24px 24px 0 0; background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  box-shadow: var(--shadow-pop); animation: sgi-up .2s ease-out; }
@keyframes sgi-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sgi-sheet::before { content: ""; display: block; width: 38px; height: 4px; margin: 0 auto 6px; border-radius: 4px; background: var(--line2); }
.sgi-sheet-h { display: flex; align-items: center; gap: 8px; }
.sgi-sheet-h h3 { margin: 0; font: 650 19px/1.2 var(--f-head, inherit); letter-spacing: -.02em; }
.sgi-cnt { padding: 1px 9px; border-radius: 999px; background: var(--raise2); color: var(--text2); font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.sgi-x { margin-left: auto; }
.sgi-people { list-style: none; margin: 6px 0 0; padding: 0; }
.sgi-people li { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sgi-people li:last-child { border-bottom: 0; }
.sgi-pname { flex: 1 1 auto; min-width: 0; display: grid; }
.sgi-pname b { font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.sgi-pname small { color: var(--muted); font-size: 12px; }
.sgi-sheet-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.sgi-leave { width: 100%; min-height: 48px; margin-top: 14px; border: 1px solid var(--line2); border-radius: 14px; background: none; color: var(--coral);
  font: inherit; font-weight: 650; cursor: pointer; }
.sgi-leave:hover { border-color: var(--soft-line); background: var(--soft); }
.sgi-screen button:focus-visible, .sgi-input:focus-visible, .sgi-bub:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }
.sgi-input:focus-visible { outline-offset: 0; border-color: transparent; }
@media (min-width: 760px) {
  .sgi-top { padding-left: max(4px, calc(50% - 366px)); padding-right: max(10px, calc(50% - 360px)); }
}
@media (prefers-reduced-motion: reduce) { .sgi-screen, .sgi-sheet { animation: none; } .sgi-send { transition: none; } }

/* Месячный рейтинг: отдельное чтение, компактная таблица в чате. */
.sgi-rank { flex: 0 0 auto; background: var(--panel); border-bottom: 1px solid var(--line); }
.sgi-rank[hidden], .sgi-rank-body[hidden] { display: none; }
.sgi-rank > * { box-sizing: border-box; max-width: 720px; margin-inline: auto; }
.sgi-rank-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 14px; border: 0; background: none; color: var(--text); font: 600 14px/1.3 var(--f-body, sans-serif); text-align: left; cursor: pointer; }
.sgi-rank-toggle > span { flex: 1; }
.sgi-rank svg { width: 18px; height: 18px; flex: 0 0 18px; }
.sgi-rank-toggle > svg { color: var(--muted); }
.sgi-rank-body { max-height: 36vh; overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 10px; }
.sgi-rank-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sgi-rank-nav b { font-size: 14px; text-align: center; }
.sgi-rank-step, .sgi-rank-retry { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--raise); color: var(--text); font: inherit; cursor: pointer; }
.sgi-rank-retry { padding: 0 16px; }
.sgi-rank-step:disabled { opacity: .35; cursor: default; }
.sgi-ranking { border-collapse: collapse; table-layout: fixed; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.sgi-ranking th { color: var(--muted); font-size: 11px; font-weight: 500; padding: 8px 4px; text-align: left; }
.sgi-ranking th:first-child { width: 44px; } .sgi-ranking th:last-child { width: 54px; text-align: right; }
.sgi-ranking td { padding: 8px 4px; border-top: 1px solid var(--line); }
.sgi-rank-person { display: flex; align-items: center; gap: 8px; }
.sgi-rank-person .sgi-pav { flex: 0 0 28px; width: 28px; height: 28px; font-size: 10px; }
.sgi-rank-name { min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.sgi-rank-name small { display: block; color: var(--muted); font-size: 11px; }
.sgi-rank-pos { color: var(--muted); } .sgi-rank-count { text-align: right; font-weight: 700; }
.sgi-rank-me { background: var(--soft); }
.sgi-rank-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
