/* Shared viewport control; outside body because body uses a brightness filter. */
.back-to-top {
  position: fixed;
  right: calc(24px + env(safe-area-inset-right, 0px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid #ff9900;
  border-radius: 50%;
  background: #292929;
  color: #ffb347;
  box-shadow: 0 3px 12px #0005;
  cursor: pointer;
  touch-action: manipulation;
}
.back-to-top[hidden] { display: none; }
body.light ~ .back-to-top { background: #fff; color: #873600; border-color: #873600; }
.back-to-top:hover { opacity: 1; background: #3b3025; }
body.light ~ .back-to-top:hover { background: #fff0dd; }
.back-to-top:focus-visible { outline: 3px solid #408cff; outline-offset: 4px; }
@media (max-width: 600px) {
  .back-to-top {
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

/* Constrain intrinsic widths without hiding overflowing content. */
.sidebar-status[data-availability="partial"] { color: #ffaa00; border-color: #ffaa00; background: rgba(255,170,0,.08); }
.sidebar-status[data-availability="offline"] { color: #ff4444; border-color: #ff4444; background: rgba(255,68,68,.08); }
.app-layout > *, .page-shell, .card, .card-body, .node-card,
.dashboard-grid > *, .stats-grid > *, .chart-container { min-width: 0; }
.table-container, #uptime-table-container {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
#dataStatus, #activityStatus, #authorsStatus, #historyStatus, #lastUpdate {
  overflow-wrap: anywhere;
  margin-block: 8px;
}
@media (max-width: 900px) {
  *, *::before, *::after { box-sizing: border-box; }
  body { padding: 0; }
  .page-shell { max-width: 100%; padding: 18px 12px; }
  .app-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; width: 100%; height: auto; padding: 16px 12px; }
  .sidebar-brand { flex-wrap: wrap; margin-bottom: 16px; }
  .sidebar-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-link { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 8px; overflow-wrap: anywhere; }
  .sidebar-link:hover { transform: none; }
  .dashboard-grid, .charts-grid, .bottom-grid, .method-grid { grid-template-columns: minmax(0, 1fr); }
  .stats-grid, .network-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls, .top-bar, .card-header, .node-header, .reward-search, .rewards-toolbar { flex-wrap: wrap; gap: 12px; }
  .controls > *, .top-bar > *, .reward-search > *, .rewards-toolbar > * { min-width: 0; max-width: 100%; }
  button, select, input:not([type="checkbox"]):not([type="range"]) { min-height: 44px; max-width: 100%; font-size: 16px; }
  button { white-space: normal; overflow-wrap: anywhere; }
  input[type="checkbox"] { width: 22px; height: 22px; }
  input[type="range"] { min-height: 44px; max-width: 100%; }
  .toggle-container { max-width: 100%; flex-wrap: wrap; }
  .toggle-container label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
  .rpc-profile-header { min-width: 0; }
  .rpc-profile-header > div { min-width: 0; }
  .rpc-profile-url, .profile-box, .method, .small, .stat-value, h1, h2, h3 { overflow-wrap: anywhere; }
  .card, .node-card { max-width: 100%; }
  .chart-container, .rewards-chart { position: relative; width: 100%; max-width: 100%; }
  canvas { max-width: 100%; }
  #uptimeTable { min-width: 620px; }
  th button, th[onclick] { min-height: 44px; }
  th[onclick] { padding-block: 14px; }
}
@media (max-width: 480px) {
  .stats-grid, .network-stats-grid { grid-template-columns: minmax(0, 1fr); }
  .node-header, .card-header { align-items: flex-start; }
  .dashboard-header h1, h1 { font-size: 1.65rem; }
  .author-sort-btn { width: auto; min-width: 44px; }
}
