*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, p { margin: 0; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul { margin: 0; padding: 0; list-style: none; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.section-label {
  margin: 26px 0 12px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Author display rules must not defeat the HTML hidden attribute. */
[hidden] { display: none !important; }
.hidden { display: none !important; }

.missing-page { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 40px var(--page-gutter) var(--content-bottom); text-align: center; }
.missing-page .crest { width: 54px; height: 54px; }
.missing-page h1 { font-family: var(--font-serif); font-size: 32px; }
.missing-page p { color: var(--text-muted); font-size: 13px; }
.missing-page .primary-button { max-width: 260px; margin-top: 10px; }

:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.bottom-nav {
  position: fixed;
  z-index: 40;
  inset: auto 0 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  background: rgba(9, 9, 11, 0.98);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #757176;
  transition: color 160ms ease;
}
.tab .icon { width: 21px; height: 21px; }
.tab span { font-size: 10px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; }
.tab.is-active { color: var(--text); }

.sheet-backdrop, .table-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.66);
  animation: fade-in 180ms ease;
}

.bottom-sheet {
  position: fixed;
  z-index: 61;
  inset: auto 0 0;
  max-height: min(76vh, 620px);
  overflow: auto;
  padding: 10px var(--page-gutter) calc(26px + var(--safe-bottom));
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.7);
  animation: sheet-up 220ms ease;
}
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 14px; border-radius: 4px; background: #444045; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 18px; font-weight: 650; }
.sheet-content { color: var(--text-muted); font-size: 14px; }
.sheet-content p + p { margin-top: 12px; }
.sheet-content strong { color: var(--text); }

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 18px);
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-card);
  animation: toast-in 200ms ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toast-in { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

@media (min-width: 768px) {
  .bottom-nav { inset: 0 auto 0 0; width: 88px; height: 100vh; padding: 20px 0; border-top: 0; border-right: 1px solid var(--border); grid-template-columns: 1fr; grid-auto-rows: 72px; align-content: start; }
  .bottom-sheet { inset: 16px 16px auto auto; width: 380px; max-height: calc(100vh - 32px); border-radius: 20px; border-bottom: 1px solid var(--border); }
  .toast { bottom: 24px; }
  main:not(.table-page) { margin-left: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
