/* ============================================================
   Base — Reset, typography, app shell
   ============================================================ */

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

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

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--body);
  background: var(--cream);
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tablet: subtle frame for tablet-sized browsers (still mobile-app feel) */
@media (min-width: 640px) and (max-width: 1023.98px) {
  body {
    background: radial-gradient(ellipse at top, var(--cream) 0%, var(--cream-dark) 100%);
  }
}

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

button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-h1); font-weight: 800; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p { color: var(--body); }

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

/* ── App shell ───────────────────────────────────────────── */
/* Fixed viewport height so bottom tab-bar is always anchored. */
.app {
  width: 100%;
  max-width: var(--app-max-w);
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  background: var(--cream);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tablet (640-1023): wider canvas, subtle side shadow */
@media (min-width: 640px) and (max-width: 1023.98px) {
  .app {
    max-width: 560px;
    box-shadow: 0 0 40px rgba(26, 29, 61, 0.08);
  }
}

.app-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 16px);
  -webkit-overflow-scrolling: touch;
}

/* Utility */
.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;
}

.stack-sm > * + * { margin-top: var(--s-2); }
.stack > * + * { margin-top: var(--s-4); }
.stack-lg > * + * { margin-top: var(--s-6); }

.px { padding-left: var(--s-5); padding-right: var(--s-5); }
.py { padding-top: var(--s-5); padding-bottom: var(--s-5); }

.row { display: flex; align-items: center; gap: var(--s-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }

.text-muted { color: var(--muted); }
.text-meta { font-size: var(--fs-sm); color: var(--muted); }
.text-xs { font-size: var(--fs-xs); }
.text-center { text-align: center; }

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

/* Scrollbar for desktop preview */
.app-body::-webkit-scrollbar { width: 4px; }
.app-body::-webkit-scrollbar-track { background: transparent; }
.app-body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }
