:root {
  --kast-bg: #F2F3F7;
  --kast-card: #FFFFFF;
  --kast-ink: #0E1120;
  --kast-muted: #5B6072;
  --kast-primary: #3452F5;
  --kast-success: #1F7A47;
  --kast-success-bg: #DFF1E6;
  --kast-missing: #A8481A;
  --kast-missing-bg: #FCE7D8;
  --kast-missing-border: #D98A5A;
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--kast-bg);
  color: var(--kast-ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body { margin: 0; min-height: 100dvh; background: var(--kast-bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.035em;
  font-weight: 700;
  margin: 0;
}

.card {
  background: var(--kast-card);
  border-radius: 24px;
  box-shadow: 0 8px 24px rgba(14, 17, 32, 0.06);
}

.btn-pill,
.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 1.25rem;
  border-radius: 28px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
}
.btn-primary { background: var(--kast-primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  background: #fff;
  color: var(--kast-ink);
  border: 1px solid rgba(14, 17, 32, 0.08);
}

.search-pill {
  width: 100%;
  min-height: 44px;
  border-radius: 28px;
  background: #fff;
  padding: 0 1.1rem;
  border: 1px solid rgba(14, 17, 32, 0.08);
  box-shadow: 0 4px 16px rgba(14, 17, 32, 0.05);
  outline: none;
}
.search-pill:focus {
  border-color: rgba(52, 82, 245, 0.45);
  box-shadow: 0 0 0 3px rgba(52, 82, 245, 0.18);
}

.grid-missing {
  background: var(--kast-missing-bg);
  color: var(--kast-missing);
  border: 1px dashed var(--kast-missing-border);
}
.grid-owned { background: var(--kast-primary); color: #fff; }

.bottom-nav {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  padding: 0.45rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(14, 17, 32, 0.12);
  border: 1px solid rgba(14, 17, 32, 0.06);
}
.nav-icon {
  display: flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--kast-muted);
}
.nav-icon-active { background: var(--kast-primary); color: #fff; }

/* Layout helpers */
.mx-auto { margin-left: auto; margin-right: auto; }
.min-h-dvh { min-height: 100dvh; }
.min-h-\[80dvh\] { min-height: 80dvh; }
.w-full { width: 100%; }
.max-w-lg { max-width: 32rem; }
.max-w-md { max-width: 28rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.pt-6 { padding-top: 1.5rem; }
.pb-1 { padding-bottom: 0.25rem; }
.pb-2 { padding-bottom: 0.5rem; }
.pb-28 { padding-bottom: 7rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mt-10 { margin-top: 2.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-auto { margin-top: auto; }
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }
.flex-1 { flex: 1 1 0%; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.min-w-0 { min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.w-3 { width: 0.75rem; }
.w-10 { width: 2.5rem; }
.w-12 { width: 3rem; }
.w-14 { width: 3.5rem; }
.h-6 { height: 1.5rem; }
.h-10 { height: 2.5rem; }
.h-12 { height: 3rem; }
.h-full { height: 100%; }
.aspect-square { aspect-ratio: 1 / 1; }
.aspect-\[3\/4\] { aspect-ratio: 3 / 4; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 999px; }
.border { border: 1px solid rgba(14, 17, 32, 0.08); }
.border-t { border-top: 1px solid rgba(14, 17, 32, 0.08); }
.border-r { border-right: 1px solid rgba(14, 17, 32, 0.08); }
.divide-y > * + * { border-top: 1px solid rgba(14, 17, 32, 0.06); }
.bg-black { background: #000; }
.bg-white { background: #fff; }
.bg-white\/15 { background: rgba(255, 255, 255, 0.15); }
.bg-kast-bg { background: var(--kast-bg); }
.bg-kast-bg\/70 { background: rgba(242, 243, 247, 0.7); }
.bg-kast-primary { background: var(--kast-primary); }
.bg-kast-success-bg { background: var(--kast-success-bg); }
.bg-kast-missing-bg { background: var(--kast-missing-bg); }
.text-white { color: #fff; }
.text-white\/80 { color: rgba(255, 255, 255, 0.8); }
.text-kast-ink { color: var(--kast-ink); }
.text-kast-muted { color: var(--kast-muted); }
.text-kast-primary { color: var(--kast-primary); }
.text-kast-success { color: var(--kast-success); }
.text-kast-missing { color: var(--kast-missing); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-\[11px\] { font-size: 11px; }
.text-\[15px\] { font-size: 15px; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.shadow-md { box-shadow: 0 4px 10px rgba(14, 17, 32, 0.12); }
.object-cover { object-fit: cover; }
.pointer-events-none { pointer-events: none; }
.cursor-pointer { cursor: pointer; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.inset-0 { inset: 0; }
.inset-y-0 { top: 0; bottom: 0; }
.left-0 { left: 0; }
.z-30 { z-index: 30; }
.block { display: block; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.hover\:bg-kast-bg:hover { background: var(--kast-bg); }
.hover\:bg-kast-bg\/70:hover { background: rgba(242, 243, 247, 0.7); }

@media (min-width: 1024px) {
  .lg\:flex { display: flex; }
  .lg\:hidden { display: none; }
  .lg\:max-w-none { max-width: none; }
  .lg\:px-0 { padding-left: 0; padding-right: 0; }
  .lg\:px-8 { padding-left: 2rem; padding-right: 2rem; }
  .lg\:pb-8 { padding-bottom: 2rem; }
  .lg\:pt-8 { padding-top: 2rem; }
  .lg\:pl-\[248px\] { padding-left: 248px; }
  .lg\:mt-0 { margin-top: 0; }
  .lg\:grid { display: grid; }
  .lg\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .lg\:grid-cols-\[1fr_320px\] { grid-template-columns: 1fr 320px; }
  .lg\:gap-8 { gap: 2rem; }
}

/* —— App shell / desktop —— */
.app-shell {
  min-height: 100dvh;
}
.app-main {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 7rem;
}
.side-nav { display: none; }
.mobile-only-hide { display: none; }
.desktop-only-hide { display: block; }

@media (min-width: 1024px) {
  .bottom-nav { display: none; }
  .desktop-only-hide { display: none; }
  .mobile-only-hide { display: block; }

  .app-shell--nav {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100dvh;
  }

  .side-nav {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    background: #fff;
    border-right: 1px solid rgba(14, 17, 32, 0.06);
    padding: 1.75rem 1.25rem;
  }
  .side-nav__brand {
    font-size: 1.75rem;
    color: var(--kast-ink);
  }
  .side-nav__links {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 2.5rem;
  }
  .side-nav__link {
    display: block;
    border-radius: 1rem;
    padding: 0.7rem 0.9rem;
    font-size: 15px;
    font-weight: 600;
    color: var(--kast-muted);
  }
  .side-nav__link:hover { background: var(--kast-bg); color: var(--kast-ink); }
  .side-nav__link.is-active {
    background: var(--kast-primary);
    color: #fff;
  }
  .side-nav__profile {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(14, 17, 32, 0.06);
  }

  .app-main {
    max-width: none;
    margin: 0;
    padding: 2rem 2.5rem 3rem;
  }

  .desktop-home__header {
    display: grid;
    grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
    gap: 2rem;
    align-items: end;
  }
  .desktop-home__search { max-width: 640px; }

  .desktop-home__stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(220px, 1.2fr);
    gap: 1rem;
    margin-top: 1.75rem;
  }
  .desktop-home__scan {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-decoration: none;
  }

  .desktop-home__split {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.25rem;
    margin-top: 1.25rem;
    align-items: start;
  }
  .desktop-home__spines {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 0.65rem;
    align-items: flex-end;
    min-height: 180px;
  }
  .desktop-home__spine {
    width: 3.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
  }
  .desktop-home__spine-book {
    width: 2.75rem;
    border-radius: 6px;
    box-shadow: 0 6px 14px rgba(14, 17, 32, 0.12);
  }
  .desktop-home__spine-label {
    font-size: 10px;
    line-height: 1.2;
    color: var(--kast-muted);
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
  }
  .desktop-home__row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.75rem;
    border-radius: 1rem;
  }
  .desktop-home__row:hover { background: var(--kast-bg); }
  .desktop-home__num {
    width: 2.5rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.65rem;
    background: var(--kast-bg);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--kast-muted);
    flex-shrink: 0;
  }
}
