@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,500&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --cream: #F6F4EE;
  --cream-deep: #ECE8DE;
  --cream-right: #F1EDE4;
  --surface: #FFFFFF;
  --ink: #1A1C22;
  --ink-soft: #7A7E88;
  --ink-faint: #A8ABB4;
  --coral: #E96E6D;
  --coral-soft: #F7D4D3;
  --green: #3F6B4A;
  --gold: #B8893A;
  --line: #E4E0D6;
  --shadow: 0 18px 40px rgba(26, 28, 34, 0.1);
  --shadow-soft: 0 8px 24px rgba(26, 28, 34, 0.06);
  /* Soft book lift like a printed cover: spine crease + bottom-right cast */
  --book-shadow:
    inset 2px 0 3px rgba(0, 0, 0, 0.14),
    inset 6px 0 10px rgba(0, 0, 0, 0.04),
    3px 6px 10px rgba(26, 28, 34, 0.1),
    8px 16px 28px rgba(26, 28, 34, 0.14),
    14px 28px 48px rgba(26, 28, 34, 0.1);
  --book-shadow-lift:
    inset 2px 0 3px rgba(0, 0, 0, 0.16),
    inset 7px 0 12px rgba(0, 0, 0, 0.05),
    4px 10px 14px rgba(26, 28, 34, 0.12),
    10px 22px 36px rgba(26, 28, 34, 0.16),
    18px 36px 60px rgba(26, 28, 34, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --pill: 999px;
  --sidebar-w: 78px;
  --sidebar-expanded-w: 210px;
  --space-xs: 8px;
  --space-sm: 14px;
  --space-md: 22px;
  --space-lg: 36px;
  --space-xl: 48px;
  --page-x: 40px;
  --page-y: 28px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Outfit', sans-serif;
  font-weight: 400;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--cream);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-mark svg { width: 18px; height: 18px; display: block; }

.brand-name {
  display: block;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-tag {
  display: block;
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* ─── App shell ─── */
.app-body {
  display: flex;
  min-height: 100vh;
  background:
    linear-gradient(105deg, #FFFFFF 0%, #FFFFFF 48%, var(--cream) 48%, var(--cream) 100%);
}

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 22px 12px;
  background: rgba(255, 255, 255, 0.72);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: width .28s ease;
  overflow: visible;
}

body.sidebar-expanded .app-sidebar {
  width: var(--sidebar-expanded-w);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
  margin-bottom: 8px;
  position: relative;
  text-decoration: none;
}

.sidebar-logo .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: auto 0;
  align-items: stretch;
}

.side-link {
  min-height: 44px;
  width: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-soft);
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  padding: 0;
  font: inherit;
  text-decoration: none;
  transition: background .2s ease, color .2s ease, width .28s ease, border-radius .28s ease;
}

.side-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.side-label {
  display: none;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  color: inherit;
}

.brand-side-label {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

body.sidebar-expanded .side-link {
  width: 100%;
  border-radius: 14px;
  justify-content: flex-start;
  padding: 0 12px;
}

body.sidebar-expanded .side-label { display: inline; }

.side-link:hover {
  color: var(--ink);
  background: rgba(26, 28, 34, 0.05);
}

.side-link.active {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 10px 20px rgba(233, 110, 109, 0.28);
}

.side-bottom { margin-top: auto; align-self: center; }
body.sidebar-expanded .side-bottom { align-self: stretch; }

/* Tooltips only when sidebar is collapsed */
body:not(.sidebar-expanded) .side-link[data-tooltip]::after,
body:not(.sidebar-expanded) .sidebar-logo[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
  z-index: 60;
  box-shadow: var(--shadow-soft);
}

body:not(.sidebar-expanded) .side-link[data-tooltip]:hover::after,
body:not(.sidebar-expanded) .side-link[data-tooltip]:focus-visible::after,
body:not(.sidebar-expanded) .sidebar-logo[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.app-frame {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 26px var(--page-x) 14px;
}

.app-search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-faint);
}

.app-search svg { width: 18px; height: 18px; flex-shrink: 0; }

.app-search input {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
  padding: 8px 0;
}

.app-search input::placeholder { color: var(--ink-faint); }

.app-search-static {
  font-size: 14px;
  color: var(--ink-soft);
}

.app-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2C3344, #1A1C22);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: color .18s ease, border-color .18s ease;
}

.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--ink); border-color: var(--ink-faint); }

.app-main {
  flex: 1;
  padding: 18px var(--page-x) var(--space-xl);
  animation: rise .45s ease both;
  overflow: visible;
  position: relative;
  z-index: 1;
}

.dash-foot {
  position: relative;
  z-index: 1;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 22px;
  border-radius: var(--pill);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 10px 22px rgba(26, 28, 34, 0.18);
}
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn-danger {
  background: transparent;
  color: var(--coral);
  border-color: var(--coral-soft);
}
.btn-sm { padding: 8px 14px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  display: inline-grid;
  place-items: center;
}

.btn-icon svg { width: 17px; height: 17px; }

/* ─── Home dashboard ─── */
.dash-hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-xl);
  align-items: start;
  padding: var(--space-md) 0 var(--space-sm);
}

.dash-hero h1 {
  font-family: 'Fraunces', serif;
  font-size: clamp(36px, 5vw, 52px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.06;
  margin: 0 0 var(--space-sm);
  max-width: 11ch;
}

.dash-hero .lede {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.6;
  max-width: 38ch;
  margin: 0 0 var(--space-md);
}

.author-spot {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 16px;
  align-items: start;
  padding-top: 10px;
}

.author-spot .author-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--cream-deep), #d9d2c4);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.author-spot-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.author-spot .label {
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: lowercase;
  margin: 0 0 2px;
}

.author-spot h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

.author-spot p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.55;
  font-family: 'Fraunces', serif;
  font-style: italic;
}

.spot-more {
  border: none;
  background: transparent;
  color: var(--ink-faint);
  letter-spacing: .12em;
  cursor: default;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.carousel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-lg) 0 var(--space-sm);
}

.carousel-controls {
  display: flex;
  gap: 8px;
}

.carousel-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .18s ease, box-shadow .18s ease;
}

.carousel-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

/* Keep hero / filters under the raised active cover */
.dash-hero,
.carousel-toolbar {
  position: relative;
  z-index: 1;
}

/* Full-width focus carousel — absolute slots, smooth left transitions */
.carousel-bleed {
  width: calc(100% + 72px);
  margin-left: -36px;
  margin-right: -36px;
  padding: 4px 0 8px;
  overflow-x: clip; /* hide wrap teleports at the edges */
  overflow-y: visible; /* let the active cover rise above the section above */
  position: relative;
  z-index: 80;
}

.carousel {
  width: 100%;
  overflow: visible;
  position: relative;
  z-index: 80;
}

.carousel-track {
  position: relative;
  width: 100%;
  min-height: 380px;
  padding: 56px 48px 28px;
  overflow: visible;
  z-index: 80;
}

.carousel-card {
  position: absolute;
  bottom: 28px;
  left: 50%;
  width: clamp(110px, 11vw, 148px);
  text-align: center;
  transform: translateX(-50%) translateY(0) scale(1);
  opacity: 0.78;
  transition:
    left .65s cubic-bezier(.22,.7,.25,1),
    transform .65s cubic-bezier(.22,.7,.25,1),
    opacity .45s ease,
    width .65s cubic-bezier(.22,.7,.25,1),
    filter .45s ease;
  filter: saturate(0.94);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  will-change: left, transform, opacity;
  z-index: 1;
}

.carousel-card.no-anim {
  transition: none !important;
}

.carousel-card.is-near {
  opacity: 0.92;
  filter: saturate(0.98);
  z-index: 20;
}

.carousel-card.is-active {
  width: clamp(150px, 14.5vw, 200px);
  transform: translateX(-50%) translateY(-36px) scale(1.12);
  opacity: 1;
  filter: saturate(1);
  z-index: 200 !important;
  pointer-events: auto;
}

.carousel-card.is-far {
  opacity: 0.72;
  z-index: 2;
}

.carousel-card.is-out {
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

.carousel-card .cover {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 0;
  box-shadow: var(--book-shadow);
  display: block;
  object-fit: cover;
  background: var(--cream-deep);
}

.carousel-card.is-active .cover {
  box-shadow: var(--book-shadow-lift);
}

.carousel-card h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 12px 0 2px;
  line-height: 1.3;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity .35s ease, max-height .35s ease, margin .35s ease;
}

.carousel-card .author {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity .35s ease, max-height .35s ease;
}

.carousel-card.is-active h3,
.carousel-card.is-active .author {
  opacity: 1;
  max-height: 3em;
}

.carousel-card.is-active h3 {
  font-size: 14px;
  margin: 14px 0 2px;
}

#carouselAuthor {
  transition: opacity .28s ease;
}

#carouselAuthor.is-fading {
  opacity: 0.35;
}

.book-rail {
  display: flex;
  gap: 26px;
  overflow-x: auto;
  padding: 16px 4px 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.book-rail::-webkit-scrollbar { height: 0; }

.book-rail-compact .rail-card { flex-basis: 132px; }

.rail-card {
  flex: 0 0 150px;
  scroll-snap-align: start;
  transition: transform .22s ease;
}

.rail-card:hover { transform: translateY(-6px); }

.rail-card .cover {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 0;
  box-shadow: var(--book-shadow);
  display: block;
  object-fit: cover;
  background: var(--cream-deep);
}

.rail-card h3 {
  font-size: 13.5px;
  font-weight: 700;
  margin: 12px 0 2px;
  line-height: 1.3;
}

.rail-card .author {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0;
}

.home-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
}

.collection-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: var(--space-md);
}

.collection-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid transparent;
  transition: background .18s ease, border-color .18s ease;
}

.collection-row:hover {
  background: var(--surface);
  border-color: var(--line);
}

.collection-row .cover {
  width: 52px;
  aspect-ratio: 2/3;
  border-radius: 0;
  box-shadow: var(--book-shadow);
}

.collection-row h3 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
}

.collection-row p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.collection-meta {
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
}

.dash-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
  padding: var(--space-md) 0 var(--space-sm);
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-soft);
}

.dash-foot .accent { color: var(--coral); font-weight: 700; }
.dash-foot .count { font-weight: 700; white-space: nowrap; }
.dash-foot .count em {
  font-style: normal;
  color: var(--coral);
  font-family: 'Fraunces', serif;
  font-size: 18px;
}

.foot-info {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-faint);
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
  vertical-align: middle;
}

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 var(--space-md);
}

.filters-inline { margin: 0; } /* keep toolbar filters flush */

.filters select {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--ink);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin: 0 0 var(--space-md);
}

.section-head h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.section-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--coral);
}

/* ─── Book grid (activity / fallback) ─── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 28px 24px;
}

.book-card {
  background: transparent;
  border: none;
  border-radius: var(--radius);
  overflow: visible;
  position: relative;
  transition: transform .22s ease;
}

.book-card:hover { transform: translateY(-6px); }
.book-card .punch { display: none; }

.cover {
  width: 100%;
  aspect-ratio: 2/3;
  display: block;
  border-radius: 0;
  box-shadow: var(--book-shadow);
  background: var(--cream-deep);
  object-fit: cover;
}

.card-body { padding: 16px 2px 4px; }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.code {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: .04em;
}

.book-card h3 {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 2px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.book-card .author {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

.book-card .synopsis {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0 0 10px;
  min-height: 36px;
}

.card-foot {
  padding-top: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--ink-soft);
}

.stamp {
  display: inline-block;
  border: none;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: var(--pill);
  white-space: nowrap;
  background: var(--cream-deep);
}

.stamp.green { color: var(--green); background: #E4EDE4; }
.stamp.gold { color: var(--gold); background: #F4EADB; }
.stamp.red { color: var(--coral); background: var(--coral-soft); }
.stamp.ink { color: var(--ink); background: var(--cream-deep); }

.pill {
  font-size: 11.5px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  padding: 5px 11px;
  border-radius: var(--pill);
  background: var(--surface);
}

/* Price tag on covers */
.cover-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.cover-wrap .cover {
  width: 100%;
}

.price-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(26, 28, 34, 0.08);
  padding: 5px 7px;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(26, 28, 34, 0.14);
  pointer-events: none;
  white-space: nowrap;
}

.carousel-card.is-active .price-tag {
  font-size: 11px;
  padding: 6px 8px;
}

.book-rail-compact .price-tag {
  top: 6px;
  right: 6px;
  font-size: 9px;
  padding: 4px 6px;
}

/* Detail glance row: availability, genre, price */
.detail-glance {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 16px 0 18px;
}

.detail-glance .stamp,
.detail-glance .pill {
  font-size: 11px;
  padding: 7px 11px;
}

.price-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--cream-deep);
  color: var(--ink);
  line-height: 1.2;
}

/* Cream/gold — distinct from the ink primary CTA button */
.price-chip-buy {
  background: #F4EADB;
  color: var(--gold);
  border-color: #e5d0b0;
  box-shadow: none;
}

.price-chip-borrow {
  background: #E4EDE4;
  color: var(--green);
  border-color: #c9d8cb;
}

.price-chip-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.78;
}

.price-chip-value {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ─── Book detail — 1144px frame, cover overlapping white sheet ─── */
body.is-detail .app-main {
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 48px;
}

body.is-detail.app-body,
.app-body.is-detail {
  background: var(--cream);
}

.detail-page {
  position: relative;
  overflow: visible;
  padding: 12px 0 0;
}

.detail-frame {
  width: min(1144px, calc(100% - 96px));
  max-width: 1144px;
  margin: 0 auto;
}

.detail-hero {
  --detail-cover-w: 320px;
  --detail-action-h: 48px;
  --detail-sheet-pad-top: 20px;
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 44px var(--detail-cover-w) 1fr;
  gap: 20px 40px;
  align-items: end;
  padding: 16px 48px 0;
  box-sizing: border-box;
}

.detail-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: center;
  justify-self: end;
}

.detail-nav a {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-size: 14px;
  transition: border-color .18s ease, color .18s ease, background .18s ease;
}

.detail-nav a:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
  background: var(--surface);
}

.detail-cover-wrap {
  position: relative;
  z-index: 30;
  /* Pull cover down so its bottom edge lines up with the CTA / icons */
  margin-bottom: calc(-1 * (var(--detail-sheet-pad-top) + var(--detail-action-h)));
}

.detail-cover-wrap .cover {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 0;
  display: block;
  object-fit: cover;
  box-shadow: var(--book-shadow-lift);
}

.detail-intro {
  align-self: end;
  /* Leave room for the action row that sits beside the cover bottom */
  padding: 8px 0 calc(var(--detail-sheet-pad-top) + var(--detail-action-h) + 16px);
  max-width: 520px;
}

.detail-intro h1 {
  font-family: 'Fraunces', serif;
  font-size: clamp(30px, 3.8vw, 42px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 8px;
}

.detail-intro .byline {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
}

.detail-intro .blurb {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: 40ch;
  margin: 0;
}

.detail-sheet {
  --detail-cover-w: 320px;
  --detail-action-h: 48px;
  --detail-sheet-pad-top: 20px;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  background: var(--surface);
  padding: var(--detail-sheet-pad-top) 48px 48px;
  box-shadow:
    0 -8px 32px rgba(26, 28, 34, 0.04),
    0 18px 48px rgba(26, 28, 34, 0.08);
  min-height: 380px;
}

/* Cover gutter | actions — bottoms share one line with the cover */
.detail-sheet-head {
  display: grid;
  grid-template-columns: 44px var(--detail-cover-w) 1fr;
  gap: 20px 40px;
  align-items: end;
  min-height: var(--detail-action-h);
  margin: 0 0 36px;
}

.detail-cover-gutter {
  grid-column: 2;
  height: var(--detail-action-h);
}

.detail-actions {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-width: 0;
  min-height: var(--detail-action-h);
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.detail-actions-icons {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.detail-sheet .detail-actions .btn-primary {
  padding: 13px 24px;
  font-size: 14px;
}

.detail-sheet .detail-actions .btn-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  background: #F1EEE7;
  border: none;
  color: var(--ink);
  cursor: pointer;
}

.detail-sheet .detail-actions .btn-icon:hover {
  background: var(--cream-deep);
}

.detail-sheet-body {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: var(--space-xl) 80px;
  align-items: start;
}

.detail-request {
  margin: 0;
  padding: 0;
  border: none;
  max-width: none;
}

/* ─── Request modal ─── */
body.modal-open {
  overflow: hidden;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 28, 34, 0.45);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(26, 28, 34, 0.22);
  padding: 28px 28px 32px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.modal-head h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink-soft);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--cream-deep);
  color: var(--ink);
}

.modal-body .muted {
  margin: 0 0 20px;
}

.field-hint {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.45;
}


.terms-agree {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
}

.terms-agree input {
  margin-top: 3px;
  flex-shrink: 0;
}

.toggle-btn {
  cursor: pointer;
}

.detail-desc h3,
.detail-request h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 18px;
}

.detail-desc .prose {
  font-size: 14.5px;
  color: #555963;
  line-height: 1.75;
  margin: 0 0 16px;
  max-width: 54ch;
}

.review-snip {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  margin-top: 36px;
  align-items: start;
}

.review-snip .avatar { width: 44px; height: 44px; font-size: 14px; }

.review-snip strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 4px;
}

.review-snip p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  font-style: italic;
}

.detail-side {
  padding-top: 2px;
}

.meta-block { margin-bottom: 28px; }

.meta-block h4 {
  margin: 0 0 8px;
  font-size: 13.5px;
  font-weight: 700;
}

.meta-block p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.65;
}

.detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 14px;
}

.ledger-note {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.55;
}

.ledger-note.warn { color: var(--coral); }
.ledger-note.info { color: var(--gold); }


.ledger-box {
  border: none;
  background: #FBFAf7;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.7;
}

.ledger-box .warn { color: var(--coral); }
.ledger-box .info { color: var(--gold); }

/* ─── Forms ─── */
.form-card {
  max-width: 640px;
  background: var(--surface);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow-soft);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  display: block;
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  font-family: 'Outfit', sans-serif;
  font-size: 14.5px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #FBFaf7;
  color: var(--ink);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: rgba(233, 110, 109, 0.55);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(233, 110, 109, 0.12);
}

.form-group textarea { resize: vertical; min-height: 90px; }

.toggle-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Must follow .toggle-row so grid beats flex */
.toggle-row.courier-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  flex-wrap: nowrap;
}

.toggle-row.courier-row .toggle-btn {
  flex: none;
  min-width: 0;
  width: 100%;
  padding: 12px 8px;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toggle-btn {
  flex: 1;
  min-width: 110px;
  padding: 11px;
  border-radius: var(--pill);
  font-family: 'Outfit', sans-serif;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: center;
}

.toggle-btn.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
}

.notice {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 22px;
}

.notice.ok { background: #e4ede4; color: var(--green); }
.notice.err { background: var(--coral-soft); color: #9B3A39; }
.notice.info { background: #f4eadb; color: var(--gold); }

.terms-box {
  font-size: 12.5px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 14px 0;
  line-height: 1.6;
  background: #FBFAf7;
}

.terms-box strong { color: var(--ink); }

.pipeline-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 14px;
  box-shadow: var(--shadow-soft);
}

.pipeline-row {
  display: grid;
  grid-template-columns: 70px 1.6fr 1fr 1.2fr auto;
  gap: 16px;
  align-items: center;
  padding: 18px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.pipeline-row:last-child { border-bottom: none; }
.pipeline-row .sub { font-size: 12px; color: var(--ink-soft); }
.pipeline-actions { display: flex; gap: 6px; justify-self: end; flex-wrap: wrap; }

/* ─── Admin desk ─── */
.admin-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.admin-eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.admin-eyebrow a {
  color: inherit;
  text-decoration: none;
}

.admin-eyebrow a:hover { color: var(--ink); }

.admin-title {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.admin-count-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: var(--pill);
  background: var(--cream-deep);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 8px 0 28px;
}

.admin-stat-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.admin-stat-card:hover {
  border-color: #cfc8b8;
  transform: translateY(-1px);
}

.admin-stat-card .num {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
}

.admin-stat-card .label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.admin-stat-card .hint {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.35;
}

.admin-stat-card.warn { border-color: #e4c89a; }
.admin-stat-card.danger { border-color: #e8b4b3; }

.admin-section { margin-bottom: 28px; }

.admin-section-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.admin-section-head h2 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.admin-section-head .muted { margin: 0; }

.admin-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.admin-row {
  width: 100%;
  display: grid;
  grid-template-columns: 72px minmax(0, 1.8fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: background 0.12s ease;
}

.admin-row:last-child { border-bottom: none; }
.admin-row:hover,
.admin-row:focus-visible {
  background: #FAF8F3;
  outline: none;
}

.admin-row-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.admin-row-main strong {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-row .sub {
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-row-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
  justify-self: end;
}

.admin-row:hover .admin-row-hint { color: var(--ink-soft); }

.admin-empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
}

.admin-empty .muted { margin: 0; }

.admin-filters { margin: 0 0 16px; }

.admin-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  margin-top: 8px;
  padding-top: 8px;
}

.admin-quick-links a {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
}

.admin-quick-links a:hover { color: var(--ink); }

.admin-modal-panel {
  width: min(560px, 100%);
}

.admin-modal-hero {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.admin-modal-cover {
  width: 72px;
  height: 104px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--book-shadow);
  background: var(--cream-deep);
}

.admin-modal-hero h4 {
  margin: 6px 0 4px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.admin-modal-hero .muted { margin: 0 0 10px; }

.admin-modal-summary {
  margin: 0 0 18px !important;
}

.admin-detail-grid {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0 0 18px;
  padding: 14px 16px;
  background: var(--cream);
  border-radius: 14px;
}

.admin-detail-grid dt {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.admin-detail-grid dd {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink);
  word-break: break-word;
}

.admin-modal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.admin-modal-links:empty { display: none; margin: 0; }

.admin-modal-links a {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.admin-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-modal-actions:empty { display: none; }

.admin-modal-actions .btn { min-width: 140px; }

.section-title {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 4px 0 var(--space-md);
}

.muted { color: var(--ink-soft); font-size: 13.5px; line-height: 1.55; }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0 var(--space-lg); }

.stat-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  min-width: 140px;
  box-shadow: var(--shadow-soft);
}

.stat-box .num {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 700;
}

.stat-box .label {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

/* ─── Auth pages ─── */
.auth-body {
  min-height: 100vh;
  display: flex;
  background:
    radial-gradient(900px 480px at 0% 0%, rgba(233, 110, 109, 0.1), transparent 55%),
    radial-gradient(700px 420px at 100% 100%, rgba(26, 28, 34, 0.05), transparent 50%),
    linear-gradient(160deg, #F8F6F0 0%, var(--cream) 45%, #F0EBE3 100%);
}

.auth-shell {
  width: min(1080px, 100%);
  margin: auto;
  padding: 28px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 28px;
  align-items: stretch;
}

.auth-brand {
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 560px;
  animation: rise .6s ease both;
}

.auth-brand .brand { margin-bottom: 36px; }

.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--coral);
  margin-bottom: 18px;
}

.auth-brand h1 {
  font-family: 'Fraunces', serif;
  font-size: clamp(36px, 4.5vw, 52px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin: 0 0 16px;
  max-width: 11ch;
}

.auth-brand .lede {
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: 34ch;
  margin: 0;
}

.auth-shelf {
  margin-top: 48px;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  perspective: 800px;
}

.auth-book {
  width: 72px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-book:nth-child(1) {
  height: 110px;
  background: linear-gradient(145deg, #2C3344, #1A1C22);
  animation: floaty-a 5s ease-in-out infinite;
}

.auth-book:nth-child(2) {
  height: 132px;
  width: 84px;
  background: linear-gradient(145deg, #E96E6D, #C55453);
  animation: floaty-b 5s ease-in-out .4s infinite;
}

.auth-book:nth-child(3) {
  height: 118px;
  background: linear-gradient(145deg, #D7C4A3, #B89A6A);
  animation: floaty-c 5s ease-in-out .8s infinite;
}

.auth-panel {
  display: flex;
  align-items: center;
  animation: rise .65s ease .08s both;
}

.auth-card {
  width: 100%;
  background: var(--surface);
  border-radius: 28px;
  padding: 40px 36px 36px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.auth-card h2 {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

.auth-card .auth-sub {
  color: var(--ink-soft);
  font-size: 14.5px;
  margin: 0 0 28px;
  line-height: 1.45;
}

.auth-card .btn-primary {
  width: 100%;
  padding: 14px 22px;
  margin-top: 6px;
  font-size: 15px;
}

.auth-links {
  margin-top: 22px;
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
}

.auth-links a {
  color: var(--coral);
  font-weight: 600;
}

/* install.php requirement checks */
.install-checks {
  list-style: none;
  margin: 0 0 20px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 14px;
  font-size: 12.5px;
  background: var(--cream);
  border-radius: 12px;
}

.install-checks li.ok { color: var(--green); }
.install-checks li.fail { color: #9B3A39; font-weight: 600; }

.auth-demo {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.55;
  text-align: center;
}

.auth-demo a {
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 22px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

.auth-back:hover { color: var(--ink); }

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

@keyframes floaty-a {
  0%, 100% { transform: rotateY(8deg) rotateZ(-4deg) translateY(0); }
  50% { transform: rotateY(8deg) rotateZ(-4deg) translateY(-7px); }
}

@keyframes floaty-b {
  0%, 100% { transform: rotateY(-4deg) rotateZ(2deg) translateY(0); }
  50% { transform: rotateY(-4deg) rotateZ(2deg) translateY(-10px); }
}

@keyframes floaty-c {
  0%, 100% { transform: rotateY(6deg) rotateZ(-1deg) translateY(0); }
  50% { transform: rotateY(6deg) rotateZ(-1deg) translateY(-6px); }
}

/* Mobile brand in topbar — hidden on desktop */
.mobile-brand {
  display: none;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--ink);
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.mobile-brand .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
}

.mobile-brand .brand-mark svg { width: 15px; height: 15px; }

/* Bottom tab bar — hidden on desktop */
.mobile-nav {
  display: none;
}

@media (max-width: 980px) {
  .app-body { background: var(--cream); }
  .dash-hero { grid-template-columns: 1fr; gap: 24px; }
  .author-spot { max-width: none; }
  .carousel-bleed {
    width: calc(100% + 32px);
    margin-left: -16px;
    margin-right: -16px;
  }
  .carousel-track {
    min-height: 260px;
    padding: 28px 20px 12px;
  }
  .carousel-card { width: clamp(96px, 22vw, 128px); }
  .carousel-card.is-active {
    width: clamp(140px, 34vw, 180px);
    transform: translateX(-50%) translateY(-16px) scale(1.06);
  }
  /* No title / author under the focused cover on small screens */
  .carousel-card h3,
  .carousel-card .author,
  .carousel-card.is-active h3,
  .carousel-card.is-active .author {
    display: none;
  }
  .author-spot,
  #carouselAuthor {
    display: none;
  }
  .detail-frame {
    width: calc(100% - 32px);
  }
  .detail-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 20px;
    padding: 8px 16px 0;
  }
  .detail-nav {
    flex-direction: row;
    justify-self: center;
    order: -1;
    gap: 12px;
    margin-bottom: 4px;
  }
  .detail-nav a {
    width: 40px;
    height: 40px;
    background: var(--surface);
  }
  .detail-cover-wrap {
    margin-bottom: 0; /* no overlap into title on stacked mobile layout */
    width: min(200px, 52vw);
  }
  .detail-cover-wrap .cover {
    box-shadow: var(--book-shadow);
  }
  .detail-intro {
    max-width: 100%;
    width: 100%;
    padding: 8px 8px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
  }
  .detail-intro h1 {
    font-size: clamp(26px, 7vw, 34px);
    margin: 0 0 10px;
    max-width: 16ch;
  }
  .detail-intro .byline {
    margin: 0 0 16px;
  }
  .detail-intro .blurb {
    max-width: 36ch;
    margin: 0;
    font-size: 14.5px;
    line-height: 1.6;
  }
  .detail-glance {
    justify-content: center;
    margin: 0 0 16px;
    gap: 8px;
  }
  .detail-sheet {
    padding: 24px 20px 36px;
    margin-top: 8px;
  }
  .detail-sheet-head {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 28px;
  }
  .detail-cover-gutter { display: none; }
  .detail-actions {
    grid-column: 1;
    width: 100%;
  }
  .detail-sheet-body {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .detail-desc .prose { max-width: none; }
}

@media (max-width: 860px) {
  /* Remove desktop sidebar; use bottom nav */
  .app-sidebar { display: none !important; }

  .app-body {
    background: var(--cream);
    display: block;
  }

  .app-frame {
    min-height: 100vh;
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-brand { display: inline-flex; }

  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    align-items: stretch;
    justify-content: space-around;
    gap: 4px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(10px);
    box-shadow: 0 -8px 24px rgba(26, 28, 34, 0.06);
  }

  .mobile-nav-link {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 4px;
    border-radius: 14px;
    color: var(--ink-soft);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
  }

  .mobile-nav-link svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }

  .mobile-nav-link span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-nav-link.active {
    color: var(--coral);
    background: rgba(233, 110, 109, 0.1);
  }

  .app-topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand user"
      "search search";
    align-items: center;
    gap: 14px 16px;
    padding: 16px 20px 14px;
  }

  .mobile-brand {
    grid-area: brand;
    justify-self: start;
    gap: 12px;
  }

  .mobile-brand .brand-mark {
    width: 36px;
    height: 36px;
  }

  .app-user {
    grid-area: user;
    justify-self: end;
  }

  .app-search,
  .app-search-static {
    grid-area: search;
    max-width: none;
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--pill);
    background: var(--surface);
    gap: 12px;
  }

  .app-search input {
    font-size: 14.5px;
    padding: 0;
  }

  .app-user {
    gap: 8px;
  }

  .app-user .btn-sm {
    padding: 9px 14px;
    font-size: 12.5px;
  }

  .app-main {
    padding: 16px 20px 36px;
  }

  body.is-detail .app-main {
    padding-bottom: 36px;
  }

  .user-name { display: none; }

  .dash-hero {
    gap: var(--space-lg);
    padding: var(--space-sm) 0 var(--space-md);
  }
  .dash-hero h1 { font-size: clamp(28px, 8vw, 36px); }
  .dash-hero .lede { font-size: 14.5px; margin-bottom: 20px; }

  .hero-actions { margin-top: 4px; }

  .section-head {
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
  }

  .home-section {
    margin-top: 40px;
    padding-top: 18px;
  }

  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 16px;
  }

  .book-rail {
    gap: 18px;
    padding: 14px 2px 10px;
  }
  .rail-card { flex-basis: 140px; }

  .filters {
    width: 100%;
    gap: 10px;
    margin-bottom: 20px;
  }
  .filters select { flex: 1; min-width: 0; }

  .stat-row { gap: 12px; margin-bottom: 28px; }
  .stat-box {
    flex: 1 1 calc(50% - 12px);
    min-width: 120px;
    padding: 18px;
  }

  .pipeline-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 18px 2px;
  }
  .pipeline-actions { justify-self: start; }

  .admin-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-title { font-size: 24px; }

  .admin-row {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 10px 12px;
  }

  .admin-row .stamp { grid-column: 2; justify-self: start; }
  .admin-row-hint { display: none; }

  .admin-detail-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .admin-detail-grid dt { margin-top: 6px; }
  .admin-detail-grid dt:first-child { margin-top: 0; }

  .admin-modal-actions .btn {
    flex: 1 1 100%;
    min-width: 0;
  }

  .form-row { grid-template-columns: 1fr; gap: 16px; }
  .form-group { margin-bottom: 18px; }

  .dash-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-top: 20px;
    padding-top: 18px;
  }

  .carousel-toolbar {
    flex-wrap: wrap;
    gap: 12px;
    margin: 28px 0 12px;
  }

  .collection-list { gap: 12px; margin-top: 16px; }
  .collection-row {
    grid-template-columns: 48px 1fr;
    padding: 14px;
  }
  .collection-meta { display: none; }

  .detail-frame { width: 100%; }
  .detail-page { padding-top: 4px; }
  .detail-hero {
    padding-left: 0;
    padding-right: 0;
    gap: 22px;
  }
  .detail-cover-wrap {
    margin-bottom: 0;
    width: min(210px, 54vw);
  }
  .detail-intro {
    padding: 12px 4px 24px;
  }
  .detail-intro h1 {
    margin-bottom: 12px;
  }
  .detail-sheet { padding: 28px 20px 40px; }
  .detail-sheet-body { gap: 32px; }
  .detail-actions {
    flex-wrap: wrap;
    height: auto;
    min-height: 0;
    gap: 14px;
    padding-bottom: 20px;
  }
  .detail-actions-icons { margin-left: 0; gap: 10px; }
  .meta-block { margin-bottom: 24px; }

  .modal {
    padding: 0;
    align-items: end;
  }

  .modal-panel {
    width: 100%;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    padding: 22px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .toggle-row:not(.courier-row) {
    flex-direction: column;
  }

  .toggle-row:not(.courier-row) .toggle-btn {
    min-width: 0;
    width: 100%;
  }

  .toggle-row.courier-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .toggle-row.courier-row .toggle-btn {
    white-space: normal;
    line-height: 1.2;
    font-size: 11.5px;
    padding: 10px 6px;
  }

  .price-tag {
    font-size: 9px;
    padding: 4px 6px;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    max-width: 480px;
    padding: 20px;
  }
  .auth-brand { min-height: 0; padding: 20px 8px 8px; }
  .auth-brand h1 { max-width: none; font-size: 34px; }
  .auth-shelf { display: none; }
  .auth-card { padding: 28px 22px; border-radius: 22px; }
}

@media (max-width: 420px) {
  .app-topbar {
    padding-left: 16px;
    padding-right: 16px;
    gap: 12px;
  }
  .app-main { padding-left: 16px; padding-right: 16px; }
  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 12px;
  }
  .detail-glance { gap: 8px; }
  .price-chip { padding: 7px 10px; }
  .price-chip-value { font-size: 13px; }
  .mobile-nav-link { font-size: 9.5px; }
  .detail-sheet { padding: 24px 16px 36px; }
}
