/* App shell: PWA, tabbar, toast, theme */

html[data-theme="light"] {
  --bg: #f0f3f8;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --text-muted: #64748b;
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  --surface-header: rgba(240, 243, 248, 0.96);
  --surface-panel: #f0f3f8;
  --accent-dim: rgba(57, 217, 138, 0.12);
}

html[data-theme="dark"] {
  --surface-header: rgba(11, 15, 20, 0.92);
  --surface-panel: rgba(0, 0, 0, 0.22);
}

.app-splash {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg);
  color: var(--text);
  transition: opacity 0.35s ease;
}

.app-splash.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.app-splash p {
  margin: 0;
  font-weight: 700;
  font-size: 1.1rem;
}

/* display:flex на баннерах перебивает UA [hidden] — скрываем по умолчанию, показываем только .is-visible */
.offline-banner:not(.is-visible),
.install-banner:not(.is-visible),
.offline-banner[hidden],
.install-banner[hidden] {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: none !important;
}

.offline-banner.is-visible,
.install-banner.is-visible {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  visibility: visible;
  height: auto;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
}

.offline-banner.is-visible {
  background: #7f1d1d;
  color: #fecaca;
}

.install-banner.is-visible {
  flex-wrap: wrap;
  justify-content: space-between;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.install-banner__text {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.install-banner__hint {
  margin: 4px 0 0;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-muted);
}

.brand__link--static {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  background: transparent;
  color: var(--text);
}

.btn--sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.topbar__back {
  flex-shrink: 0;
}

.topbar__title {
  display: none;
}

.topbar__title[hidden] {
  display: none !important;
}

body[data-app-view="feed"] .topbar__title,
body:not([data-app-view]) .topbar__title {
  display: none;
}

.topbar--sub .brand__tagline {
  display: none;
}

.topbar--sub .brand__name {
  font-size: 0.95rem;
}

.topbar--sub {
  gap: 8px;
}

.topbar--sub .brand {
  flex: 1;
  min-width: 0;
}

.topbar--sub .brand__link--static {
  padding: 4px 0;
}

body.pwa-standalone .install-banner {
  display: none !important;
}

.app-view[hidden] {
  display: none !important;
}

:root {
  --tabbar-height: 40px;
  /* полная высота блока таббара с отступами и safe-area */
  --tabbar-block-height: calc(4px + var(--tabbar-height) + max(4px, var(--safe-bottom)));
}

body.app--hide-tabbar #app-tabbar {
  display: none !important;
}

.tabbar {
  position: relative;
  width: 100%;
  min-height: var(--tabbar-height);
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  padding: 4px 10px max(4px, var(--safe-bottom));
  background: rgba(11, 15, 20, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 40;
}

html[data-theme="light"] .tabbar {
  background: rgba(255, 255, 255, 0.94);
}

.tabbar__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 6px;
  min-height: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  touch-action: manipulation;
}

.tabbar__btn.is-active {
  color: var(--accent);
  background: var(--accent-dim);
}

.tabbar__icon {
  font-size: 1.45rem;
  line-height: 1;
}

.tabbar__label {
  font-size: 0.77rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
}

.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-height) + 8px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100% - 24px));
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: none;
}

.toast--ok {
  border-color: rgba(57, 217, 138, 0.35);
  color: var(--accent);
}

.toast--error {
  border-color: rgba(255, 77, 109, 0.35);
  color: #ff8fa3;
}

.feed-pull {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.feed-pull.is-pulling,
.feed-pull.is-refreshing {
  max-height: 32px;
  padding: 6px 0;
}

.feed-pull.is-refreshing .feed-pull__hint::after {
  content: " · обновляем…";
}

.vote-row--touch .vote-btn {
  touch-action: manipulation;
}

.score,
.hero__score .score {
  font-variant-numeric: tabular-nums;
}

.profile-logout {
  display: block;
  width: calc(100% - 24px);
  margin: 12px auto 8px;
}

#view-profile {
  padding-bottom: 8px;
}
