*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
h1, h2, h3, h4, p, figure { margin: 0; }
a { color: var(--accent); }
button { font-family: inherit; }
img { max-width: 100%; display: block; }
.tabular { font-variant-numeric: tabular-nums; }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky; top: 0; z-index: 20;
  /* B9 — the header sat under the status bar / notch on iOS; grow the header
     by the safe-area inset and push its content down by the same amount. */
  height: calc(52px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; gap: var(--sp-3);
  padding-left: var(--sp-4); padding-right: var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header h1 {
  font-size: 20px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* P2 — focus() is called programmatically after every navigation (router.js
   focusHeading); browsers can still classify that as :focus-visible when the
   prior input was a keyboard/link activation, painting a ring that reads as
   a rendering glitch. This heading is never a real interactive target, so
   its outline is suppressed unconditionally while real focus-visible targets
   elsewhere keep theirs. */
h1[tabindex="-1"]:focus { outline: none; }
.header-back, .header-action {
  min-width: var(--tap); min-height: var(--tap);
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
}
.header-back:hover, .header-action:hover { background: var(--surface-2); }
.header-action svg, .header-back svg { width: 22px; height: 22px; }
/* B8 — [hidden] was being overridden by the `display: flex` above, so a
   hidden header button stayed in layout, in the tab order, and in the a11y
   tree. */
.header-back[hidden], .header-action[hidden] { display: none; }

.offline-bar {
  background: var(--warn);
  color: #1A1005;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 6px var(--sp-4);
}
.offline-bar[hidden] { display: none; }

main#view {
  flex: 1;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) calc(64px + env(safe-area-inset-bottom) + var(--sp-4));
}

.no-nav main#view {
  padding-bottom: var(--sp-4);
  max-width: 420px;
}

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav[hidden] { display: none; }
.bottom-nav a {
  flex: 1;
  min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a[aria-current="page"] { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
