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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  height: 100%;
}

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

body {
  font-family: var(--font-sans);
  font-weight: var(--fw-regular);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--ink);
  background-color: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10000;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  mix-blend-mode: multiply;
}

[data-theme="dark"] body::after,
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::after { mix-blend-mode: soft-light; opacity: 0.04; } }

h1 { font-family: var(--font-serif); font-size: var(--fs-3xl); font-weight: var(--fw-regular); line-height: var(--lh-tight); letter-spacing: -0.02em; }
h2 { font-family: var(--font-serif); font-size: var(--fs-2xl); font-weight: var(--fw-regular); line-height: var(--lh-tight); letter-spacing: -0.01em; }
h3 { font-family: var(--font-serif); font-size: var(--fs-xl); font-weight: var(--fw-regular); line-height: var(--lh-snug); }
h4 { font-family: var(--font-sans); font-size: var(--fs-md); font-weight: var(--fw-semibold); line-height: var(--lh-snug); }

.text-serif { font-family: var(--font-serif); }
.text-sans { font-family: var(--font-sans); }
.text-mono { font-family: var(--font-mono); font-size: 0.9em; font-variant-numeric: tabular-nums; }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.text-2 { color: var(--ink-2); }
.text-3 { color: var(--ink-3); }
.text-accent { color: var(--accent); }

.num-display {
  font-family: var(--font-serif);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.num-data {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.9em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

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

::selection { background-color: var(--accent-subtle); color: var(--ink); }

img, svg { display: block; max-width: 100%; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  -webkit-appearance: none;
  appearance: none;
}

button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

ul, ol { list-style: none; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--radius-full); }

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

.hidden { display: none !important; }

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

#main {
  flex: 1;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
  position: relative;
}

.page {
  padding: var(--space-20) var(--space-16) var(--space-32);
  animation: pageIn var(--dur-slow) var(--ease-out) both;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  padding: var(--space-24) var(--space-16) var(--space-16);
  position: sticky;
  top: var(--sync-bar-height);
  z-index: 50;
  background: var(--bg);
}

.page-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: var(--line);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: var(--space-16) 0;
}
