.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: var(--app-max-width);
  margin-inline: auto;
  background: var(--bg);
  /*
   * Second line of defence behind base.css's html/body rule: iOS has a long
   * history of ignoring a root-level overflow-x for touch panning, so the
   * shell clips its own children too. `clip` makes no scroll container, so
   * the sticky nav still sticks to the viewport and the fixed pages are
   * untouched (a fixed box's containing block is the viewport, not this).
   */
  overflow-x: clip;
}

/* Only wider than the shell itself — i.e. a desktop tab. In Telegram the app
   is full-bleed and the frame never shows. */
@media (min-width: 500px) {
  .app {
    box-shadow: 0 0 0 1px var(--border), 0 24px 64px -32px rgb(30 30 30 / 0.25);
  }
}

.app__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-5);
}

/*
 * One pane per bottom-nav tab (app.js, TabPanes.js). Each is a flex column so
 * the home pane's .app__main keeps its flex: 1 through the wrapper; `hidden`
 * has to be spelled out because the class's display beats the UA's [hidden].
 */
.tab-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  opacity: 1;
  transition:
    opacity var(--duration) var(--easing),
    transform var(--duration) var(--easing);
}

.tab-pane[hidden] {
  display: none;
}

/*
 * The switch between panes (TabPanes.js), a fade-through. The pane leaving
 * fades on the press timing — going down is quick and linear, INTERACTIONS.md's
 * own rule — and the one arriving rises 8px through its fade on the ordinary
 * `--duration`: a shorter climb than the fixture page's 12px entrance, since
 * this is a sibling taking the same ground rather than a page opening on
 * top. `--easing` for both, not `--spring`: the pane is appearing, not
 * being thrown, and nothing here has a reason to overshoot.
 *
 * No transform at rest, on purpose. A transformed ancestor becomes the
 * containing block for anything `position: fixed` inside it, and the slip
 * and tools panes both float their toasts that way — so the rest state has
 * to be `transform: none`, and the rise is only ever the enter state's.
 */
.tab-pane[data-state="leave"] {
  opacity: 0;
  transition-duration: var(--duration-press);
}

.tab-pane[data-state="enter"] {
  opacity: 0;
  transform: translateY(8px);
}

/*
 * Sticky rather than fixed: the bar reserves its own space at the end of the
 * column, so the last match row is never trapped underneath it at full scroll.
 * The gutters around the floating bar pass clicks through to the list.
 */
.app__nav {
  position: sticky;
  bottom: 0;
  z-index: 10;
  /*
   * Clear whichever bottom obstruction is larger: the device safe area, or
   * the slice of the window Telegram's own chrome is currently covering
   * (--tg-chrome-inset, kept in sync from viewportStableHeight).
   */
  padding: var(--space-2) var(--space-3)
    calc(var(--space-5) + max(var(--safe-bottom), var(--tg-chrome-inset, 0px)));
  pointer-events: none;
}

/*
 * A screen, not a message — INTERACTIONS.md's own words: an icon, one sentence
 * and one clear next action. The column layout holds for the bare one-line form
 * too (app.js's fixtures-failed state is a plain <p> wearing this class), since
 * a lone text node becomes an anonymous flex item and centres like the rest.
 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* White disc lifted off the page by its hairline and shadow — the same card
   treatment every other surface gets, at the size an empty screen can carry. */
.empty-state__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-card);
  color: var(--text-muted);
}

/* Wrapped well before the shell's width: a single sentence set to the full
   column reads as a paragraph rather than as a caption. */
.empty-state__message {
  max-width: 30ch;
}

/*
 * Boot spinner — up for exactly as long as the startup fixtures fetch (see
 * app.js). Centred in the viewport's upper half, where the list it stands in
 * for is about to appear.
 */
.boot-loading {
  display: grid;
  place-items: center;
  min-height: 70dvh;
}

.boot-loading__spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--surface-pressed);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: boot-spin 0.9s linear infinite;
}

@keyframes boot-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Slower, not still: a frozen ring reads as a hang, which is the one thing a
   loading state exists to deny. */
@media (prefers-reduced-motion: reduce) {
  .boot-loading__spinner {
    animation-duration: 2.5s;
  }
}
