/* App shell: one centered column for every screen (phone and desktop) */
.tx-app { position: relative; z-index: 10; min-height: 100vh; min-height: 100dvh; }

.tx-screen { display: none; padding-bottom: calc(var(--tx-dock-h) + 28px + var(--tx-safe-bottom)); }
.tx-app[data-view="wall"] #screen-wall,
.tx-app[data-view="settings"] #screen-settings,
.tx-app[data-view="profile"] #screen-profile,
.tx-app[data-view="thread"] #screen-thread,
.tx-app[data-view="channel"] #screen-channel { display: block; }

.tx-app[data-view="settings"], .tx-app[data-view="profile"], .tx-app[data-view="channel"] { background: var(--tx-bg); }
.tx-app[data-view="channel"] .tx-dock, .tx-app[data-view="channel"] .tx-dock-fade { display: none; }
.tx-app[data-view="channel"] #screen-channel { padding-bottom: calc(24px + var(--tx-safe-bottom)); }
.tx-app[data-view="thread"] .tx-dock { display: none; }
.tx-app[data-view="thread"] #screen-thread { padding-bottom: calc(76px + var(--tx-safe-bottom)); }

.tx-column {
  width: 100%;
  max-width: var(--tx-column-w);
  margin: 0 auto;
  padding: 0 10px;
  box-sizing: border-box;
}

/* ---------- Floating glass header (Telegram chat header) ---------- */
.tx-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + var(--tx-safe-top)) 0 8px;
}

.tx-glass {
  background: var(--tx-glass);
  backdrop-filter: var(--tx-glass-blur);
  -webkit-backdrop-filter: var(--tx-glass-blur);
  box-shadow: inset 0 0 0 0.5px var(--tx-glass-border), inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 18px rgba(0, 0, 0, 0.28);
}

.tx-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.15s ease, background 0.15s ease;
}
.tx-circle:active { transform: scale(0.94); }
.tx-circle .icon { font-size: 25px; }

.tx-pill {
  flex: 1;
  min-width: 0;
  height: 50px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 5px;
  cursor: pointer;
}
.tx-pill-text { min-width: 0; display: flex; flex-direction: column; }
.tx-pill-title { font-size: 17.5px; font-weight: 600; display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; }
.tx-pill-title > span { overflow: hidden; text-overflow: ellipsis; }
.tx-pill-sub { font-size: 14px; color: var(--tx-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Plain (black) header used by settings/profile */
.tx-titlebar { display: flex; align-items: center; gap: 4px; height: calc(56px + var(--tx-safe-top)); padding-top: var(--tx-safe-top); box-sizing: border-box; }
.tx-titlebar h1 { flex: 1; margin: 0 0 0 8px; font-size: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 0.15s ease;
}
.tx-icon-btn:hover { background: rgba(255, 255, 255, 0.07); }
.tx-icon-btn .icon { font-size: 24px; }

/* Search pill + folder tabs (wall) */
.tx-subbar { position: sticky; top: calc(56px + var(--tx-safe-top)); z-index: 29; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.tx-search { display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 8px 0 16px; border-radius: 999px; }
.tx-search .icon { font-size: 22px; color: var(--tx-text-2); }
.tx-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: #fff; font: inherit; font-size: 16.5px; }
.tx-search input::placeholder { color: var(--tx-hint); }
.tx-search input::-webkit-search-cancel-button { display: none; }

.tx-tabs { position: relative; display: flex; gap: 2px; padding: 4px; border-radius: 999px; overflow-x: auto; scrollbar-width: none; }
.tx-tab-ind { position: absolute; left: 4px; top: 4px; bottom: 4px; width: 0; border-radius: 999px; background: var(--tx-accent-soft); transition: transform .34s cubic-bezier(.3,1.25,.5,1), width .3s cubic-bezier(.2,.9,.3,1); pointer-events: none; will-change: transform; }
.tx-tabs.has-ind .tx-tab.is-active { background: transparent; }
.tx-tabs .tx-tab { position: relative; z-index: 1; }
.tx-tabs::-webkit-scrollbar { display: none; }
.tx-tab {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 15px;
  border-radius: 999px; white-space: nowrap; font-size: 15.5px; font-weight: 500; color: var(--tx-text-2);
  transition: background 0.2s ease, color 0.2s ease;
}
.tx-tab.is-active { background: var(--tx-accent-soft); color: var(--tx-accent); }

.tx-badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #fff; background: var(--tx-accent-fill);
}
.tx-tab .tx-badge { height: 20px; min-width: 20px; font-size: 12px; background: var(--tx-badge-muted); color: #000; }
.tx-tab.is-active .tx-badge { background: var(--tx-accent); color: #000; }

/* Stories avatar stack inside the header pill */
.tx-stack { display: flex; align-items: center; flex-shrink: 0; }
.tx-stack .tx-avatar { width: 38px; height: 38px; box-shadow: 0 0 0 2px #2a2a2c, 0 0 0 3.5px #3cbf7a; font-size: 14px; }
.tx-stack .tx-avatar + .tx-avatar { margin-left: -14px; }

/* States */
.tx-empty { text-align: center; padding: 48px 24px; }
.tx-empty-card { border-radius: 26px; padding: 34px 24px 28px; margin-top: 12px; }
.tx-empty-icon { width: 92px; height: 92px; border-radius: 50%; margin: 0 auto 18px; display: flex; align-items: center; justify-content: center; background: var(--tx-accent-fill); }
.tx-empty-icon .icon { font-size: 44px; color: #fff; }
.tx-empty h2 { font-size: 21px; font-weight: 700; margin: 0 0 8px; }
.tx-empty p { font-size: 15.5px; color: #c8c8cc; margin: 0 auto 22px; max-width: 340px; line-height: 1.45; }
.tx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 28px;
  border-radius: 999px; background: var(--tx-accent-fill) !important; color: #fff; font-size: 16px; font-weight: 600;
}
.tx-btn:active { transform: scale(0.97); }
.tx-sentinel { padding: 18px 0 8px; text-align: center; color: var(--tx-hint); font-size: 14px; display: flex; justify-content: center; gap: 8px; }
.tx-service {
  align-self: center; margin: 6px auto; padding: 4px 12px; border-radius: 999px;
  font-size: 14px; font-weight: 500; color: #fff; background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tx-skeleton { background: var(--tx-bubble); border-radius: var(--tx-bubble-radius); padding: 12px; }
.tx-skeleton i {
  display: block; border-radius: 8px;
  background: rgba(255, 255, 255, 0.05) linear-gradient(100deg, transparent 25%, rgba(140, 160, 255, 0.1) 45%, rgba(255, 255, 255, 0.12) 50%, rgba(140, 160, 255, 0.1) 55%, transparent 75%) no-repeat;
  background-size: 220% 100%;
  animation: tx-shimmer 1.5s linear infinite;
}
.tx-skeleton + .tx-skeleton { margin-top: 10px; }
@keyframes tx-pulse { 50% { opacity: 0.45; } }

/* Toast in Telegram style */
#toast.tx-toast {
  background: rgba(40, 40, 43, 0.96) !important;
  border: 0 !important;
  border-radius: 16px !important;
  padding: 12px 16px !important;
  font-size: 15px !important;
  bottom: calc(var(--tx-dock-h) + 28px) !important;
}

/* Floating jump-to-top button with new-posts counter (Telegram page-down style) */
.tx-jump {
  position: fixed; z-index: 38; right: max(14px, calc(50% - var(--tx-column-w) / 2 + 14px));
  bottom: calc(80px + var(--tx-safe-bottom));
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff;
  opacity: 0; transform: translateY(12px) scale(0.85); pointer-events: none;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.tx-jump.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.tx-jump .icon { font-size: 26px; transform: rotate(90deg); }
.tx-jump .tx-badge { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); height: 20px; min-width: 20px; font-size: 12px; padding: 0 6px; }
.tx-app:not([data-view="wall"]) .tx-jump { display: none; }

/* ---------- Screen transitions (View Transitions API) ---------- */
.tx-dock { view-transition-name: tx-dock; }
.tx-dock-fade { view-transition-name: tx-dock-fade; }
::view-transition-group(tx-dock), ::view-transition-group(tx-dock-fade) { animation: none; }
::view-transition-old(tx-dock), ::view-transition-new(tx-dock) { animation: none; }

/* push: new screen slides in from the right over the old one (Telegram Android) */
html[data-nav="push"]::view-transition-old(root) { animation: tx-push-out 0.32s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
html[data-nav="push"]::view-transition-new(root) { animation: tx-push-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
html[data-nav="pop"]::view-transition-old(root) { animation: tx-pop-out 0.26s cubic-bezier(0.4, 0, 0.6, 1) both; z-index: 2; }
html[data-nav="pop"]::view-transition-new(root) { animation: tx-pop-in 0.26s cubic-bezier(0.4, 0, 0.6, 1) both; }
html[data-nav="tab"]::view-transition-old(root) { animation: tx-fade-out 0.18s ease both; }
html[data-nav="tab"]::view-transition-new(root) { animation: tx-tab-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1) both; }

@keyframes tx-push-in { from { transform: translateX(100%); box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5); } to { transform: none; } }
@keyframes tx-push-out { to { transform: translateX(-22%); filter: brightness(0.6); } }
@keyframes tx-pop-out { to { transform: translateX(100%); } }
@keyframes tx-pop-in { from { transform: translateX(-22%); filter: brightness(0.6); } to { transform: none; } }
@keyframes tx-fade-out { to { opacity: 0; } }
@keyframes tx-tab-in { from { opacity: 0; transform: scale(0.985) translateY(6px); } }

/* ---------- Motion polish ---------- */
@keyframes tx-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.tx-rise { animation: tx-rise 0.38s cubic-bezier(0.2, 0.9, 0.3, 1) both; animation-delay: calc(var(--i, 0) * 38ms); }
/* press feedback everywhere: a small, springy squeeze */
button, .tx-row, .tx-dock-tab, .tx-icon-btn, .tx-chip, .tx-pf-action, .tx-mod-card { -webkit-tap-highlight-color: transparent; }
.tx-icon-btn { transition: transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1), background 0.16s; }
.tx-icon-btn:active { transform: scale(0.88); background: var(--tx-accent-soft); }
.tx-dock-tab { transition: transform 0.18s cubic-bezier(0.3, 1.4, 0.5, 1), background 0.2s, color 0.2s; }
.tx-dock-tab:active { transform: scale(0.9); }
.tx-pf-action { transition: transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1); }
.tx-pf-action:active { transform: scale(0.94); }
button.tx-row, label.tx-row { transition: background 0.18s ease, transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1); }
button.tx-row:active, label.tx-row:active { transform: scale(0.985); }
/* switch: springy thumb */
.tx-switch span::after { transition: transform 0.28s cubic-bezier(0.3, 1.5, 0.5, 1) !important; }
.tx-switch input:active + span::after { width: 26px; }
/* images fade in once loaded */
.tx-media img, .tx-avatar img { transition: opacity 0.3s ease; }

/* ---- performance: the wallpaper is painted once on its own GPU layer and stays out of page-transition snapshots ---- */
#tgx-bg-canvas, #tgx-bg-pattern { will-change: transform; transform: translateZ(0); contain: strict; backface-visibility: hidden; }
#tgx-bg-canvas { view-transition-name: tx-bg; }
#tgx-bg-pattern { view-transition-name: tx-bgp; }
::view-transition-group(tx-bg), ::view-transition-group(tx-bgp), ::view-transition-old(tx-bg), ::view-transition-new(tx-bg), ::view-transition-old(tx-bgp), ::view-transition-new(tx-bgp) { animation: none; }
::view-transition-old(tx-bg), ::view-transition-old(tx-bgp) { display: none; }

/* ---- "continue where you stopped" pill ---- */
.tx-resume { position: fixed; z-index: 40; left: 50%; top: calc(var(--tx-safe-top, 0px) + 178px); transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px 0 14px; border-radius: 999px; color: var(--tx-text); font-size: 14.5px; font-weight: 500; white-space: nowrap; animation: tx-resume-in .34s cubic-bezier(.2,.9,.3,1) both; box-shadow: 0 8px 28px rgba(0,0,0,.35); }
.tx-resume .icon { color: var(--tx-accent); font-size: 18px; }
.tx-resume.is-out { opacity: 0; transform: translate(-50%, -10px); transition: opacity .3s, transform .3s; }
@keyframes tx-resume-in { from { opacity: 0; transform: translate(-50%, -14px) scale(.96); } }
#sentinel-text a { color: var(--tx-accent); text-decoration: none; }
