/* ═══════════════════════════════════════════════════════
   Shared UI Components — Переключатель, хаб, лоадер
   ═══════════════════════════════════════════════════════ */

.book-switcher {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.switcher-btn {
  appearance: none;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #777;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 6px 10px;
  line-height: 1;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.switcher-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent-soft);
}

.switcher-btn.is-active {
  color: #f5f0e8;
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Print link ── */
.top-link-print {
  text-decoration: none;
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-soft);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  padding: 5px 7px;
  line-height: 1;
}

.top-link-print:hover {
  background: rgba(168, 136, 74, 0.1);
}

/* ── iOS Safari fix ── */
html {
  height: -webkit-fill-available;
}

body {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  max-height: 100dvh;
  max-height: -webkit-fill-available;
  overflow: hidden;
}

.bottombar {
  flex-shrink: 0;
  z-index: 40;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
  background: rgba(10, 10, 14, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.topbar {
  flex-shrink: 0;
  z-index: 40;
  padding-top: max(6px, env(safe-area-inset-top, 0px));
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* ── Hub landing page ── */
.hub-simple {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  text-align: center;
}

.hub-simple h1 {
  font-family: var(--display);
  color: var(--accent-soft);
  letter-spacing: 0.2em;
  font-weight: 500;
  font-size: clamp(28px, 8vw, 42px);
  margin: 0 0 6px;
}

.hub-simple p {
  color: #777;
  font-family: var(--serif);
  margin: 0 0 24px;
  max-width: 340px;
  line-height: 1.5;
}

.hub-switch {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(300px, 100%);
}

.hub-switch .switcher-btn {
  display: block;
  padding: 14px 18px;
  font-size: 12px;
  border-radius: 10px;
  text-align: center;
}

.hub-switch .switcher-btn small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.8;
}

.hub-badge {
  margin-top: 20px;
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #666;
  opacity: 0.7;
}

/* ── Loading spinner ── */
.boot-loading {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 200px;
  color: #777;
  font-family: var(--serif);
  font-size: 16px;
  gap: 10px;
}

.boot-loading::after {
  content: "";
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Mobile responsive ── */
@media (max-width: 720px) {
  .topbar {
    flex-wrap: nowrap;
    gap: 4px;
  }

  .book-switcher {
    order: -1;
    width: 100%;
    justify-content: center;
    margin-bottom: 1px;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 4px 8px 2px;
  }

  .switcher-btn {
    flex: 1;
    text-align: center;
    padding: 8px 8px;
    font-size: 9px;
  }

  .mobile-nav {
    display: grid !important;
  }

  .mobile-nav-btn {
    display: grid !important;
  }
}
