/* Reset, type, layout and the app shell. Tokens live in tokens.css. */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.serif {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  font-variant-numeric: lining-nums;
  margin: 0;
}

h1 {
  font-size: var(--text-3xl);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-lg);
}

p {
  margin: 0 0 var(--s3);
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-control);
}

.num {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: var(--text-sm);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

[x-cloak] {
  display: none !important;
}

/* ---- layout helpers (instead of style= attributes, which the CSP forbids) ---- */

.stack > * + * {
  margin-top: var(--s3);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s3);
  align-items: center;
}

.row.tight {
  gap: var(--s1);
}

.spread {
  justify-content: space-between;
}

.end {
  justify-content: flex-end;
}

.grow {
  flex: 1 1 16rem;
  min-width: 0;
}

.push {
  margin-left: auto;
}

.mt-0 {
  margin-top: 0;
}

.mt-2 {
  margin-top: var(--s2);
}

.mt-3 {
  margin-top: var(--s3);
}

.mt-4 {
  margin-top: var(--s4);
}

.mb-0 {
  margin-bottom: 0;
}

.mb-2 {
  margin-bottom: var(--s2);
}

.mb-3 {
  margin-bottom: var(--s3);
}

.mb-4 {
  margin-bottom: var(--s4);
}

.w-full {
  width: 100%;
}

.w-short {
  width: 5.5rem;
}

.grid {
  display: grid;
  gap: var(--s3);
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

/* ---- app shell -------------------------------------------------------------- */

.shell-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
  padding-top: var(--safe-top);
}

.shell-bar {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--s3) max(var(--s4), var(--safe-right)) var(--s3) max(var(--s4), var(--safe-left));
  display: flex;
  align-items: center;
  gap: var(--s4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.brand .mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-control);
  background: var(--primary);
  color: var(--on-primary);
}

.topnav {
  display: none;
  gap: var(--s1);
}

.topnav a,
.tabbar a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
}

.topnav a:hover {
  color: var(--ink);
  background: var(--neutral-soft);
}

.topnav a[aria-current="page"] {
  color: var(--ink);
  background: var(--neutral-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.shell-main {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--s5) max(var(--s4), var(--safe-right))
    calc(var(--s12) + 64px + var(--safe-bottom)) max(var(--s4), var(--safe-left));
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s5);
}

.page-head p {
  margin: var(--s1) 0 0;
  color: var(--muted);
}

.tabbar {
  position: fixed;
  inset: auto 0 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--card);
  border-top: 1px solid var(--hairline);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 60px;
  font-size: var(--text-sm);
  white-space: nowrap;
}

.tabbar a[aria-current="page"] {
  color: var(--link);
  font-weight: 600;
}

@media (min-width: 1024px) {
  .topnav {
    display: flex;
  }

  .tabbar {
    display: none;
  }

  .shell-main {
    padding-bottom: var(--s12);
  }
}

@media (max-width: 639px) {
  h1 {
    font-size: var(--text-2xl);
  }
}

.skip-link {
  position: absolute;
  left: var(--s3);
  top: -100px;
  z-index: 100;
  padding: var(--s2) var(--s4);
  border-radius: var(--r-control);
  background: var(--primary);
  color: var(--on-primary);
}

.skip-link:focus {
  top: var(--s3);
}

.input.w-auto {
  width: auto;
  flex: 0 1 12rem;
}
