* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  touch-action: manipulation;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-ink);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

/* Mobile/tablet: #app is the ONLY scrolling element, at a locked height.
   This is what guarantees position:fixed chrome (header, bottom nav, buy
   bar) never drifts off-screen on very long pages — a known class of bug
   on mobile browsers where fixed elements can misplace themselves once the
   document grows tall. Desktop restores ordinary page scrolling below. */
#app {
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

img {
  display: block;
  max-width: 100%;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* Chrome that should never be text-selectable, like native app UI */
.app-header, .bottom-nav, .desktop-nav, .nav-item, .p-tile__body .p-tile__cat,
.section-head, .ed-head, .filter-bar, .chip-row, .sheet__header, .cart-item__row {
  -webkit-user-select: none;
  user-select: none;
}

/* Scrollable containers get native momentum + don't leak scroll to the page behind */
.h-scroll, .collection-scroll, .sheet__body, #cart-drawer-body, .gallery, .tile-grid {
  -webkit-overflow-scrolling: touch;
}
.sheet__body, #cart-drawer-body {
  overscroll-behavior: contain;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

::selection {
  background: var(--color-accent-soft);
  color: var(--color-accent-dark);
}

::-webkit-scrollbar {
  width: 0;
  height: 0;
}

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

#app {
  max-width: var(--container);
  margin: 0 auto;
  background: var(--color-bg);
  position: relative;
  box-shadow: 0 0 60px rgba(0,0,0,0.04);
}

@media (min-width: 561px) and (max-width: 899px) {
  body {
    background: var(--color-surface-2);
  }
}

main#view {
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(var(--navbar-h) + var(--safe-bottom) + 12px);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Desktop layout ---------- */
@media (min-width: 900px) {
  /* Desktop hides the bottom nav entirely (see components.css), so the
     "lock body, scroll #app" workaround mobile needs isn't necessary here —
     restore ordinary whole-page scrolling, which desktop visitors expect. */
  html, body { height: auto; overflow: visible; }
  #app {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
    max-width: var(--container-wide);
    box-shadow: none;
  }

  main#view {
    padding-top: calc(var(--header-h) + 28px);
    padding-bottom: 60px;
    max-width: 1200px;
    margin: 0 auto;
  }
}

/* Grain removed: a crisp, clean native app doesn't wear a paper texture */
.grain-overlay { display: none; }

.script-accent {
  font-family: var(--font-script);
  font-weight: 400;
  color: var(--color-accent-dark);
  font-size: 1.5em;
  line-height: 0.7;
  display: inline-block;
  vertical-align: -0.08em;
}

/* ---------- Scroll reveal ---------- */
.reveal-init {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(6px);
  transition: opacity 900ms var(--ease-out), transform 900ms var(--ease-out), filter 900ms var(--ease-out);
}
.reveal-in {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}
@media (prefers-reduced-motion: reduce) {
  .reveal-init { opacity: 1; transform: none; filter: none; transition: none; }
}

.skeleton {
  background: linear-gradient(100deg, var(--color-surface-2) 30%, var(--color-border) 50%, var(--color-surface-2) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}
