html, body {
  overflow: hidden;
  height: 100%;
  background: var(--yaqin-bg);
  color: var(--yaqin-text);
  font-family: var(--yaqin-font);
}

.app {
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  padding-top: var(--yaqin-safe-top);
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  background: var(--yaqin-bg);
  color: var(--yaqin-text);
  box-shadow: none;
}

.brand-footer { display: none; }
.app-header {
  flex: 0 0 auto;
  position: relative;
  z-index: 20;
  height: var(--yaqin-header-h);
  min-height: var(--yaqin-header-h);
  padding: 0 var(--yaqin-gutter);
  box-sizing: border-box;
  background: var(--yaqin-surface);
  color: var(--yaqin-text);
}

.app-header h1 {
  margin: 0;
  font-size: var(--yaqin-fs-modal);
  font-weight: 700;
}
.app-header p {
  margin: 2px 0 0;
  font-size: var(--yaqin-fs-caption);
  color: var(--yaqin-text-secondary);
}
.app-header .theme-button {
  width: 40px;
  height: 40px;
  border: 0;
  background: none;
  color: var(--yaqin-text);
  font-size: 22px;
  display: grid;
  place-items: center;
}

.view {
  flex: 1;
  min-height: 0;
  height: auto !important;
  overflow-y: auto;
  overscroll-behavior: contain;
  position: relative;
  z-index: 1;
  background: var(--yaqin-bg);
}

.nav {
  bottom: var(--yaqin-nav-float-inset) !important;
  z-index: 30 !important;
  background: transparent !important;
  border-top: 0 !important;
  padding-bottom: 0 !important;
}

body.tab-shell:not(.full-screen) .view {
  /* скролл на всю высоту, включая зону под таббаром */
  padding-bottom: 0;
}
body.profile-open .view {
  height: auto !important;
  padding-bottom: 0 !important;
}
body.full-screen .app-header { display: none; }
body.full-screen .view {
  height: 100% !important;
  flex: 1;
  padding-bottom: 0;
}

.chats-head,
.modal-head,
.filters-head,
.me-top,
.gchat-top,
.sheet-head,
.picker-head,
.chat-top,
.screen-head {
  position: sticky;
  top: 0;
  z-index: 20;
  background: transparent;
  color: var(--yaqin-text);
  flex-shrink: 0;
  box-sizing: border-box;
}

/* Вкладки: прозрачный float (часто внутри .list-sticky-pill) */
.chats-head,
.me-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 calc(var(--yaqin-gutter) * -1) calc(-1 * var(--yaqin-header-h));
  padding: 6px var(--yaqin-gutter);
  min-height: var(--yaqin-header-h);
  height: var(--yaqin-header-h);
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  pointer-events: none;
}
.chats-head > *,
.me-top > * {
  pointer-events: auto;
}

/* Внутренние экраны: как главные — слева, 22px, с фоном */
.filters-head,
.modal-head,
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin: 0 calc(var(--yaqin-gutter) * -1) 12px;
  padding: 10px 16px;
  width: calc(100% + (var(--yaqin-gutter) * 2));
  min-height: 0;
  height: auto;
  background: var(--yaqin-bg) !important;
  border: 0 !important;
  box-shadow: none !important;
  pointer-events: auto;
}

/* Крестик закрытия модалки — справа, заголовок слева */
.modal-head > h1 {
  order: 1;
  flex: 1 1 auto;
}
.modal-head > .head-action {
  order: 2;
}
.modal-head > button:not(.head-action) {
  order: 3;
  margin-left: 0;
}

.chats-head h1,
.me-top h1 {
  flex: 0 1 auto;
  width: fit-content;
  max-width: min(72vw, 260px);
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  border: 0 !important;
  font-size: var(--yaqin-fs-title);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  color: var(--yaqin-text);
}

.filters-head h1,
.modal-head h1,
.sheet-head h1 {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  font-size: var(--yaqin-fs-title-sm);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  color: var(--yaqin-text);
}

/* Пустой spacer справа больше не центрирует заголовок */
.filters-head > span:empty,
.modal-head > span:empty,
.sheet-head > span:empty,
.modal-head > span.head-spacer:empty {
  display: none;
}

.chats-head button,
.me-top button,
.filters-head button,
.modal-head > button:not(.head-action),
.sheet-head button,
.events-head-actions button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  color: var(--yaqin-text);
  font-size: 22px;
  display: grid;
  place-items: center;
  flex: 0 0 40px;
}
.modal-head .head-action {
  height: 40px;
  min-width: 56px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  font-size: 15px;
  font-weight: 600;
  color: var(--yaqin-link);
  display: grid;
  place-items: center;
  margin-left: auto;
  flex: 0 0 auto;
}
.modal-head > span.head-spacer,
.sheet-head > span {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  background: transparent !important;
  box-shadow: none !important;
  pointer-events: none;
}

.events-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

/* Space under floating tab heads (list-sticky-pill pages keep their own spacing) */
.events-feed-page,
.chats-page,
.groups-tab-page,
.me-overview-page,
.me-page {
  --float-head-clearance: calc(var(--yaqin-header-h) + 10px);
}
.events-feed-page > .chats-head + *,
.chats-page > .chats-head + *,
.groups-tab-page > .chats-head + *,
.me-overview-page > .me-top + *,
.me-page > .me-top + * {
  margin-top: var(--float-head-clearance, calc(var(--yaqin-header-h) + 10px)) !important;
}

/* Page chrome: без bleed — иначе overflow:hidden + focus в поиске уезжают в scrollLeft */
.list-sticky-pill {
  position: relative;
  top: auto;
  z-index: 21;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 0 0 12px;
  padding: 10px 0;
  border-radius: 0;
  background: transparent !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none !important;
  border: 0 !important;
}
.list-sticky-pill.is-search-open {
  padding: 10px 0 14px;
}
.list-sticky-pill--compact {
  padding: 10px 0;
}
.list-sticky-pill .chats-head,
.list-sticky-pill .me-top {
  position: relative;
  top: auto;
  z-index: auto;
  margin: 0;
  height: auto;
  min-height: 0;
  padding: 0;
  pointer-events: none;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}
.list-sticky-pill .chats-head > *,
.list-sticky-pill .me-top > * {
  pointer-events: auto;
}
.list-sticky-pill .chats-head h1,
.list-sticky-pill .me-top h1 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-size: var(--yaqin-fs-title-sm);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.list-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-left: auto;
  flex: 0 0 auto;
  pointer-events: auto;
  z-index: 2;
}
.list-head-actions button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none !important;
  color: var(--yaqin-text) !important;
  font-size: 22px;
  display: grid !important;
  place-items: center;
  flex: 0 0 40px;
  opacity: 1 !important;
  visibility: visible !important;
}
.list-head-actions button.on {
  color: var(--yaqin-text) !important;
  background: transparent !important;
}
.list-sticky-pill .chats-head {
  margin-bottom: 18px;
}
.list-sticky-pill.is-search-open .chats-head {
  margin-bottom: 16px;
}
.list-sticky-pill--compact .me-top,
.list-sticky-pill--compact .chats-head {
  margin-bottom: 0;
}
.list-search-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.list-search-panel .chats-pills,
.list-search-panel .events-date-pills {
  margin: 0 !important;
  padding-bottom: 2px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.list-sticky-pill .search-box,
.list-sticky-pill .chats-search,
.list-sticky-pill .groups-search {
  margin: 0 !important;
}
.list-sticky-pill .chats-pills,
.list-sticky-pill .events-date-bar {
  margin: 0 !important;
  padding: 0 !important;
  max-width: 100%;
}
.list-sticky-pill .chats-pills {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.list-sticky-pill .groups-pills {
  margin: 0 !important;
}

/* Вкладки: скролл только у списка под chrome */
body[data-route='chats'] .view,
body[data-route='groups'] .view,
body[data-route='events'] .view,
body[data-route='me'] .view {
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* padding уезжает во внутренний скролл — иначе мёртвая зона под списком */
  padding-bottom: 0 !important;
}
.chats-page,
.groups-tab-page,
.events-feed-page,
.me-overview-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior-x: none;
  box-sizing: border-box;
  /* нижний inset только у scroll-ребёнка */
  padding-bottom: 0 !important;
  max-width: 100%;
  min-width: 0;
}
.chats-page > .list-sticky-pill + *,
.groups-tab-page > .list-sticky-pill + *,
.events-feed-page > .list-sticky-pill + *,
.me-overview-page > .page-scroll,
.page-scroll,
.chats-scroll,
.groups-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  margin-top: 0 !important;
  /* место под pill: контент скроллится за навигацией, в конце — полностью читаем */
  padding-bottom: var(--yaqin-tab-scroll-pad);
  align-content: start;
}
.me-overview-page > .page-scroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 2px;
  align-content: start;
}
/* Не сжимать блоки в flex-скролле — иначе overflow:hidden обрезает ряды без скролла */
.me-overview-page > .page-scroll > *,
.chats-page > .list-sticky-pill + * > *,
.groups-tab-page > .list-sticky-pill + * > *,
.events-feed-page > .list-sticky-pill + * > *,
.chats-scroll > *,
.groups-scroll > * {
  flex-shrink: 0;
}
.me-overview-page > .page-scroll > * {
  flex: 0 0 auto;
}

/* Списки вкладок не растягивать ряды на всю высоту flex-скролла */
.groups-tab-page > .groups-tab-list,
.chats-page > .chat-list {
  align-content: start;
  align-self: stretch;
  height: auto;
  flex: 1 1 auto;
}
.chats-page > .chat-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
/* Афиша: flex-wrap 2 колонки (без CSS Grid — иначе наслоение в WebView) */
.events-feed-page > .events-feed {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: flex-start;
  align-items: flex-start;
  height: auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  box-sizing: border-box;
}
.events-feed-page .taneesh-event-card {
  flex: 0 0 calc((100% - 12px) / 2);
  width: calc((100% - 12px) / 2);
  max-width: calc((100% - 12px) / 2);
  height: auto;
  min-width: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 0;
  isolation: isolate;
  contain: layout;
  box-sizing: border-box;
}
.events-feed-page .event-photo {
  flex: none;
  width: 100%;
  aspect-ratio: 4 / 5;
  position: relative;
  overflow: hidden;
}
.events-feed-page .event-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Shared primary pill CTA */
.empty-primary,
.filters-save,
.connected-cta,
.celebrate-primary,
.verify-cta,
.ob-next,
.photos-save,
.taneesh-buy-block,
.feedback-submit {
  padding: 16px 20px !important;
  font-size: var(--yaqin-fs-body) !important;
  font-weight: 700;
  border-radius: var(--yaqin-radius-pill);
}

.compose {
  bottom: calc(var(--yaqin-nav-pill-h) + var(--yaqin-nav-float-inset) + 12px) !important;
  width: var(--yaqin-fab-size) !important;
  height: var(--yaqin-fab-size) !important;
  font-size: 22px !important;
}

@media (min-width: 520px) {
  html, body { background: var(--yaqin-bg-subtle); }
  html[data-theme='dark'],
  html[data-theme='dark'] body {
    background: var(--yaqin-surface-raised);
  }
  .app {
    max-width: 442px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
  }
}

.yaqin-boot-error {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--yaqin-bg);
  color: var(--yaqin-text);
  padding: 24px 20px;
  font: 15px/1.45 system-ui, sans-serif;
  overflow: auto;
}
.yaqin-boot-error h1 {
  margin: 0 0 12px;
  font-size: 20px;
}
.yaqin-boot-error pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--yaqin-bg-subtle);
  padding: 12px;
  border-radius: 12px;
  font-size: 12px;
}


.head-spacer {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
}

/* Sheet/full screens: контент под шапкой Telegram */
body.sheet-view .app {
  padding-top: 0;
}
body.full-screen .app {
  padding-top: var(--yaqin-safe-top);
}
