/* app.css — Linda's Library.
 *
 * The structure is Apple HIG in the browser: a large title that folds into
 * the bar, grouped inset cards, capsule buttons, a floating tab bar in the
 * thumb zone, sheets with a grabber, 44pt targets, safe-area insets, dark
 * mode, reduced motion / transparency / contrast.
 *
 * The dress is the library itself: paper and card stock, ink, a serif for
 * titles, typewriter type for anything a librarian would have typed or
 * stamped, a green "in" stamp and a red "out" stamp, and the ruled checkout
 * card that used to live in the back of every book.
 */

/* ------------------------------------------------------------- Tokens -- */
:root {
  color-scheme: light dark;
  --bg: #f3ecdd;
  --bg-grouped: #f3ecdd;
  --card: #fffdf7;
  --card-soft: #f9f3e4;
  --label: #1d2327;
  --label-2: #565c58;
  --label-3: #7d7b70;
  --separator: rgba(29, 35, 39, .13);
  /* Library green: links, the current tab, the one primary action. */
  --tint: #1f5a4a;
  --tint-soft: #dfe8dc;
  --on-tint-soft: #1b4d3f;
  --primary: #1f5a4a;
  --on-primary: #fffdf7;
  /* The two stamps. */
  --in: #1c6a4d;
  --out: #ad3527;
  /* The checkout card. */
  --stock: #f6e7bd;
  --stock-ink: #2a2a26;
  --stock-ink-2: #6a6452;
  --rule: #9fbfd0;
  --margin-line: #d8776b;
  --danger: #b3261e;
  --shadow-card: 0 1px 2px rgba(40, 32, 12, .06), 0 5px 16px rgba(40, 32, 12, .06);
  --shadow-cover: 0 1px 2px rgba(30, 24, 10, .2), 0 8px 18px rgba(30, 24, 10, .18);
  --shadow-float: 0 8px 28px rgba(30, 24, 10, .18), 0 1px 3px rgba(30, 24, 10, .12);
  --bar-bg: rgba(243, 236, 221, .82);
  --bar-border: rgba(29, 35, 39, .12);
  --pill-bg: rgba(255, 253, 247, .86);
  --scrim: rgba(24, 22, 16, .45);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "New York", ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --type: "American Typewriter", "Courier Prime", "Courier New", ui-monospace, monospace;
  --r-card: 16px;
  --r-list: 16px;
  --r-cover: 5px;
  --r-btn: 999px;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --spring: linear(0, .01 1.2%, .05 2.5%, .2 5.3%, .78 13%, 1.04 18%, 1.08 21%, 1.07 24.5%, 1 36%, .99 43%, 1 62%, 1);
  /* The bar's full height, notch included, so content never starts under it. */
  --top-h: calc(56px + env(safe-area-inset-top, 0px));
  --bottom-h: 92px;
  --maxw: 1040px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161917;
    --bg-grouped: #161917;
    --card: #212522;
    --card-soft: #272c28;
    --label: #efe9da;
    --label-2: #b4b1a4;
    --label-3: #8b897e;
    --separator: rgba(239, 233, 218, .13);
    --tint: #86cdae;
    --tint-soft: #24352e;
    --on-tint-soft: #a5dcc3;
    --primary: #2c7560;
    --on-primary: #fffdf7;
    --in: #86cdae;
    --out: #f0907f;
    --stock: #2b2a22;
    --stock-ink: #efe6cc;
    --stock-ink-2: #aaa38c;
    --rule: rgba(140, 180, 200, .3);
    --margin-line: rgba(232, 130, 118, .55);
    --danger: #ff8a80;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .3), 0 5px 16px rgba(0, 0, 0, .22);
    --shadow-cover: 0 2px 4px rgba(0, 0, 0, .4), 0 10px 22px rgba(0, 0, 0, .4);
    --shadow-float: 0 8px 28px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
    --bar-bg: rgba(22, 25, 23, .8);
    --bar-border: rgba(239, 233, 218, .1);
    --pill-bg: rgba(38, 43, 39, .86);
    --scrim: rgba(0, 0, 0, .58);
  }
}

/* --------------------------------------------------------------- Base -- */
* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--top-h) + 12px);
  /* The document is the only scroller. No pull-to-refresh, no rubber band
     that reads as "reload" when someone drags to see the top of the page. */
  overscroll-behavior-y: none;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: -.01em;
  background: var(--bg-grouped);
  color: var(--label);
  padding-top: var(--top-h);
  padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
body.has-hero { padding-top: 0; }
a { color: var(--tint); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }
img { display: block; max-width: 100%; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--tint); outline-offset: 2px; border-radius: 6px; }
/* Headings take focus when a step changes (screen readers announce them); no ring. */
h1[tabindex]:focus, h2[tabindex]:focus { outline: none; }
.skip { position: absolute; left: -9999px; top: 0; z-index: 60; background: var(--primary); color: var(--on-primary); padding: 12px 18px; border-radius: 0 0 12px 0; font-weight: 700; }
.skip:focus { left: 0; }
.icon { flex: 0 0 auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Type: titles are set in the serif, like a title page. */
.large-title { font-family: var(--serif); font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -.015em; margin: 0; text-wrap: balance; }
.title1 { font-family: var(--serif); font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; margin: 0 0 6px; text-wrap: balance; overflow-wrap: anywhere; }
.title2 { font-family: var(--serif); font-size: 22px; line-height: 1.25; font-weight: 700; margin: 0 0 4px; }
.headline { font-size: 17px; line-height: 1.3; font-weight: 600; margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.footnote { font-size: 13px; line-height: 1.4; color: var(--label-2); }
/* Anything a librarian would have typed: labels, counts, dates. */
.hero-place { margin: 2px 0 4px; font-size: 15px; color: var(--label-2); display: flex; align-items: center; gap: 6px; }
.hero-place-link { gap: 6px; justify-content: flex-start; text-align: left; font-weight: 500; }
.hero-place svg { flex: none; }
.eyebrow { font-family: var(--type); font-size: 12px; line-height: 1.3; letter-spacing: .14em; text-transform: uppercase; color: var(--label-2); margin: 0 0 6px; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.main { min-height: 60vh; }

/* ------------------------------------------------------------ Top bar -- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  background: var(--bar-bg);
  border-bottom: 1px solid transparent;
  transition: border-color .2s var(--ease);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .topbar { -webkit-backdrop-filter: saturate(1.4) blur(18px); backdrop-filter: saturate(1.4) blur(18px); }
}
body.is-scrolled .topbar { border-bottom-color: var(--bar-border); }
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  height: var(--top-h);
  padding: 0 8px;
  padding-top: env(safe-area-inset-top);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
}
.bar-brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 8px; color: var(--label); font-family: var(--serif); font-weight: 700; font-size: 18px; justify-self: start; transition: opacity .2s var(--ease); }
.bar-brand:hover { text-decoration: none; }
.bar-brand .brand-mark { width: 28px; height: 28px; border-radius: 7px; }
.bar-brand-name { white-space: nowrap; }
.bar-back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px 0 4px; color: var(--tint); font-weight: 500; justify-self: start; }
.bar-back:hover { text-decoration: none; }
.bar-title {
  grid-column: 2; text-align: center; font-family: var(--serif); font-weight: 700; font-size: 17px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 55vw;
  opacity: 0; transform: translateY(6px);
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
body.is-collapsed .bar-title { opacity: 1; transform: none; }
/* On the shelf page the large title is the library's name; the brand in the
   bar only appears once that title has scrolled away. */
body.has-hero:not(.is-collapsed) .bar-brand { opacity: 0; pointer-events: none; }
.bar-tabs { display: none; }
.bar-actions { display: none; }
.bar-spacer { grid-column: 3; }

/* The shelf page's bookplate: name, tagline, the count as a typed line. */
.hero { padding-top: var(--top-h); }
.hero-inner { max-width: var(--maxw); margin: 0 auto; padding: 14px 16px 18px; }
.hero .large-title { font-size: 40px; }
.hero-tagline { font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--label-2); margin: 6px 0 0; }
.hero-stats { font-family: var(--type); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--label-2); margin: 16px 0 0; padding-top: 12px; border-top: 3px double var(--separator); }
.hero-stats strong { color: var(--label); font-weight: 700; }
.wrap > .large-title { padding: 10px 0 4px; }

/* ------------------------------------------------------------ Tab bar -- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; align-items: center; gap: 10px;
  padding: 8px 16px max(12px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.tabbar-pill {
  pointer-events: auto;
  display: flex; align-items: stretch;
  background: var(--pill-bg);
  border: 1px solid var(--bar-border);
  border-radius: 999px;
  box-shadow: var(--shadow-float);
  padding: 4px;
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .tabbar-pill { -webkit-backdrop-filter: saturate(1.4) blur(18px); backdrop-filter: saturate(1.4) blur(18px); }
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 64px; min-height: 52px; padding: 4px 8px; border-radius: 999px;
  color: var(--label-2); font-size: 11px; font-weight: 600; letter-spacing: 0;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.tab:hover { text-decoration: none; }
.tab .icon { width: 24px; height: 24px; }
.tab.is-current { color: var(--tint); background: color-mix(in srgb, var(--tint) 13%, transparent); }
.tab.is-current .icon { --bg: var(--card); }
/* Give (+) and Take (−): the two things you can do at a library, side by
   side in their own pill. The ring carries the stamp colour: green in, red
   out. */
.act { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.act:hover { text-decoration: none; }
.tab-act { min-width: 64px; gap: 3px; }
.act-ring {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: #fffdf7;
  transition: transform .3s var(--spring);
}
.act-left { background: #1c6a4d; }
.act-took { background: #ad3527; }
.act:active .act-ring { transform: scale(.9); }
.act:focus-within .act-ring { outline: 3px solid var(--tint); outline-offset: 2px; }
.tab-act .act-label { font-size: 11px; font-weight: 600; color: var(--label-2); }
.act-sub { display: none; }
.tabbar-pill .tab { position: relative; }
.tabbar-pill .tab::after { content: ""; position: absolute; inset: -4px 0; }

@media (max-width: 379px) {
  .tab { min-width: 56px; padding: 4px 6px; }
  .tab-act { min-width: 54px; }
  .tabbar { gap: 8px; padding-left: 10px; padding-right: 10px; }
}
/* Desktop: tabs in the bar, no bottom bar */
@media (min-width: 900px) {
  :root { --bottom-h: 0px; }
  .tabbar { display: none; }
  .topbar-inner { grid-template-columns: auto 1fr auto; padding: 0 16px; }
  .bar-title { display: none; }
  .bar-tabs { display: flex; gap: 4px; justify-content: center; grid-column: 2; }
  .bar-tabs .tab { flex-direction: row; gap: 6px; min-height: 44px; min-width: 0; padding: 0 14px; font-size: 15px; }
  .bar-tabs .tab .icon { width: 20px; height: 20px; }
  .bar-actions { display: flex; gap: 8px; grid-column: 3; justify-self: end; }
  .bar-act {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 44px; padding: 0 14px 0 6px; border-radius: 999px;
    background: color-mix(in srgb, var(--label) 6%, transparent); color: var(--label); font-weight: 600; font-size: 15px;
  }
  .bar-act:hover { background: color-mix(in srgb, var(--label) 10%, transparent); }
  .bar-act .act-ring { width: 32px; height: 32px; }
  body.has-hero:not(.is-collapsed) .bar-brand { opacity: 1; pointer-events: auto; }
  .hero .large-title { font-size: 52px; }
  .hero-inner { padding: 32px 16px 24px; }
}

/* -------------------------------------------------------------- Cards -- */
.card {
  background: var(--card); border-radius: var(--r-card);
  padding: 16px; margin: 0 0 14px;
  box-shadow: var(--shadow-card);
}
.card-soft { background: var(--card-soft); }
.card-list { padding-bottom: 8px; }

/* The two verbs, large, on the shelf page. */
.verbs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 18px; }
.verb {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  min-height: 112px; padding: 14px;
  background: var(--card); color: var(--label); border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  transition: transform .3s var(--spring);
}
.verb:active { transform: scale(.97); }
.verb .act-ring { width: 44px; height: 44px; }
.verb .act-ring .icon { width: 26px; height: 26px; }
.verb .act-label { display: block; font-size: 17px; font-weight: 600; line-height: 1.2; }
.verb .act-sub { display: block; font-size: 13px; line-height: 1.3; color: var(--label-2); margin-top: 2px; }
.verb:focus-within { outline: 3px solid var(--tint); outline-offset: 2px; }
.verb:focus-within .act-ring { outline: none; }
.verbs-row { grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) { .verbs { max-width: 560px; } }

.about-card { display: flex; gap: 16px; align-items: center; border: 3px double var(--separator); box-shadow: none; background: transparent; }
.about-card .brand-mark { border-radius: 12px; flex: 0 0 auto; }
.about-card .footnote { display: flex; align-items: center; gap: 4px; }
.about-card .footnote a { display: inline-flex; align-items: center; min-height: 44px; }

.section-h { font-family: var(--serif); font-size: 23px; font-weight: 700; margin: 26px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.section-count { font-family: var(--type); font-size: 14px; font-weight: 400; color: var(--label-2); }
.section-sub { color: var(--label-2); margin: -4px 0 12px; font-size: 15px; }
.more { margin: 4px 0 8px; font-size: 15px; font-weight: 500; }
.more a { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; }

/* ------------------------------------------------------------ Buttons -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 22px;
  border: 0; border-radius: var(--r-btn);
  font-size: 17px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
  transition: transform .3s var(--spring), filter .15s var(--ease), background .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-tonal { background: var(--tint-soft); color: var(--on-tint-soft); }
.btn-plain { background: transparent; color: var(--tint); padding: 0 14px; }
.btn-wide { width: 100%; }
.btn .icon { width: 20px; height: 20px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.actions .btn { width: 100%; }
@media (min-width: 560px) { .actions { flex-direction: row; flex-wrap: wrap; } .actions .btn { width: auto; } }
.link { background: none; border: 0; padding: 0; color: var(--tint); font-weight: 500; cursor: pointer; min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
.link-danger { color: var(--danger); }
.mini { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--tint-soft); color: var(--on-tint-soft); display: inline-flex; align-items: center; justify-content: center; }

/* ------------------------------------------------------------- Search -- */
.search-field {
  display: flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 0 10px 0 12px; margin: 0 0 4px;
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: 12px; color: var(--label-3);
}
.search-field input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: 0;
  font-size: 17px; color: var(--label); padding: 10px 0;
}
.search-field input::placeholder { color: var(--label-3); }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-field:focus-within { border-color: var(--tint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint) 25%, transparent); color: var(--label-2); }
.search-clear, .search-go { width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; color: var(--label-2); display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.search-go { color: var(--tint); }
.empty-search { color: var(--label-2); padding: 20px 0; font-size: 15px; }
.empty-search a { display: inline-flex; align-items: center; min-height: 44px; }

/* --------------------------------------------------------- Book cards -- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px 14px; margin: 0 0 8px; }
@media (min-width: 480px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 24px 18px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.book-card { display: block; color: inherit; min-width: 0; -webkit-tap-highlight-color: transparent; }
.book-card:hover { text-decoration: none; }
.cover-wrap { position: relative; }
.cover {
  width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover;
  border-radius: var(--r-cover); background: var(--card-soft);
  box-shadow: var(--shadow-cover);
}
.book-card .cover { transition: transform .35s var(--spring); }
.book-card:hover .cover { transform: translateY(-3px); }
.book-card:active .cover { transform: scale(.97); }
.cover-s { width: 40px; height: 60px; border-radius: 3px; box-shadow: 0 1px 3px rgba(30, 24, 10, .3); flex: 0 0 auto; }
.badge {
  position: absolute; top: 8px; left: -4px;
  padding: 4px 8px 3px; border-radius: 3px;
  font-family: var(--type); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  box-shadow: 0 1px 3px rgba(30, 24, 10, .3);
}
.badge-new { background: #fffdf7; color: #1c6a4d; }
.badge-out { background: #fffdf7; color: #ad3527; }
.book-card-text { padding: 9px 2px 0; }
.book-card-title { font-family: var(--serif); font-size: 16px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card-author { font-size: 13px; color: var(--label-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 16px 12px; margin: 0 -16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-padding-left: 16px; }
.strip::-webkit-scrollbar { display: none; }
.strip .book-card { flex: 0 0 112px; scroll-snap-align: start; }
.strip .cover { filter: grayscale(.55); opacity: .85; }

/* -------------------------------------------- Grouped list & the stamp -- */
.list { list-style: none; margin: 0 0 8px; padding: 0 14px; background: var(--card); border-radius: var(--r-list); box-shadow: var(--shadow-card); }
.list-plain { padding: 0; box-shadow: none; background: transparent; border-radius: 0; }
.row { display: flex; gap: 12px; align-items: flex-start; padding: 13px 0; border-bottom: 1px solid var(--separator); position: relative; }
.row:last-child { border-bottom: 0; }
.row-cover { flex: 0 0 auto; }
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.row-title a { color: var(--label); font-weight: 600; }
/* The whole row is the target (HIG list rows), not just the title text. */
.row-title a::after { content: ""; position: absolute; inset: 0; }
.row-title a:hover { text-decoration: none; }
.row:has(.row-title a:hover) { background: color-mix(in srgb, var(--label) 3%, transparent); }
.admin-row .row-title a::after, .admin .row-title a::after { content: none; }
.row-note { font-family: var(--serif); font-size: 15px; color: var(--label-2); margin-top: 2px; font-style: italic; }
.row-meta { font-size: 13px; color: var(--label-3); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* A date stamp: green when a book came in, red when one went out. */
.stamp {
  flex: 0 0 auto; min-width: 58px; padding: 5px 6px 3px; margin-top: 1px;
  border: 1.5px solid currentColor; border-radius: 4px;
  font-family: var(--type); font-size: 11px; line-height: 1.2; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; text-align: center;
  transform: rotate(-2.5deg); opacity: .92;
}
.stamp b { display: block; font-size: 13px; letter-spacing: .04em; }
.stamp-in { color: var(--in); }
.stamp-out { color: var(--out); }
.row:nth-child(even) .stamp { transform: rotate(1.5deg); }
.row:nth-child(3n) .stamp { transform: rotate(-1deg); }

/* ---------------------------------------------------------- Book page -- */
.book-hero { padding: 14px 16px 0; text-align: center; }
.book-hero-cover { position: relative; display: inline-block; width: min(46vw, 190px); }
.book-hero-cover .cover { box-shadow: 0 14px 30px rgba(30, 24, 10, .28), 0 2px 5px rgba(30, 24, 10, .2); }
.book-body { padding-top: 18px; }
.book-body .title1 { text-align: center; }
.book-meta { text-align: center; color: var(--label-2); font-size: 15px; margin: 0 0 12px; }
.status { text-align: center; margin: 0 0 6px; }
.status-stamp {
  display: inline-block; padding: 6px 12px 4px; border: 2px solid currentColor; border-radius: 5px;
  font-family: var(--type); font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  transform: rotate(-1.5deg);
}
.status.is-in { color: var(--in); }
.status.is-out { color: var(--out); }
.book-body .actions { justify-content: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0 0 18px; }
.chip { display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--separator); color: var(--label-2); font-size: 13px; font-weight: 500; text-transform: capitalize; }
.links { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin: 8px 0 20px; }
.links a, .links span { display: inline-flex; align-items: center; gap: 3px; min-height: 44px; }

/* The checkout card from the back of the book: typed heading, ruled lines,
   a red margin, one stamped line per visit. */
.libcard {
  background: var(--stock); color: var(--stock-ink);
  border-radius: 6px; margin: 0 0 14px; padding: 14px 0 0;
  box-shadow: var(--shadow-card);
  font-family: var(--type);
  overflow: hidden;
}
.libcard-head { padding: 0 14px 12px; }
.libcard-lib { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; text-align: center; color: var(--stock-ink-2); margin: 0 0 10px; }
.libcard-field { display: flex; gap: 8px; align-items: baseline; font-size: 15px; line-height: 1.35; border-bottom: 1px solid var(--rule); padding: 4px 0 3px; margin: 0; }
.libcard-field span { flex: 0 0 auto; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--stock-ink-2); }
.libcard-field b { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.libcard table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.libcard th { font-size: 11px; font-weight: 400; letter-spacing: .12em; text-transform: uppercase; text-align: left; color: var(--stock-ink-2); padding: 6px 10px 5px; border-top: 2px solid var(--stock-ink-2); }
.libcard td { padding: 9px 10px 7px; border-top: 1px solid var(--rule); vertical-align: top; font-size: 15px; line-height: 1.3; height: 44px; overflow-wrap: anywhere; }
.libcard .c-date { width: 118px; border-right: 1px solid var(--margin-line); white-space: nowrap; font-weight: 700; letter-spacing: .03em; }
.libcard .c-way { width: 54px; text-align: right; text-transform: uppercase; font-size: 12px; font-weight: 700; letter-spacing: .1em; }
.libcard tr.is-in .c-date, .libcard tr.is-in .c-way { color: var(--in); }
.libcard tr.is-out .c-date, .libcard tr.is-out .c-way { color: var(--out); }
.libcard tr.is-in .c-date span, .libcard tr.is-out .c-date span { display: inline-block; transform: rotate(-2deg); }
.libcard tr:nth-child(even) .c-date span { transform: rotate(1.5deg); }
.libcard-note { display: block; font-family: var(--serif); font-style: italic; font-size: 14px; color: var(--stock-ink-2); margin-top: 2px; }
.libcard-foot { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--stock-ink-2); padding: 9px 14px; border-top: 1px solid var(--rule); margin: 0; }

/* --------------------------------------------------------- Empty state -- */
.empty { text-align: center; padding: 32px 12px; }
.empty-art { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; border: 3px double var(--separator); color: var(--label-2); }
.empty h2 { font-family: var(--serif); font-size: 23px; margin: 0 0 6px; }
.empty p { color: var(--label-2); margin: 0 auto 18px; max-width: 34ch; }

/* ------------------------------------------------------------ Steps -- */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; }
.step-n { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--tint); color: var(--tint); font-family: var(--type); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.stat-row { display: flex; gap: 8px; }
.stat { flex: 1; text-align: center; padding: 10px 4px; border-radius: 10px; background: var(--card-soft); }
.stat-n { font-family: var(--type); font-size: 26px; font-weight: 700; }
.stat-l { font-size: 12px; color: var(--label-2); font-weight: 500; }

/* ------------------------------------------------------------ Forms -- */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--label-2); }
.field-label em { font-style: normal; font-weight: 400; color: var(--label-3); }
.field input, .field textarea, .form-inline input {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1px solid var(--separator); border-radius: 12px;
  background: var(--card); color: var(--label); font-size: 17px;
}
.sheet .field input, .sheet .field textarea { background: var(--bg); }
.field textarea { resize: vertical; line-height: 1.4; }
.field input:focus, .field textarea:focus, .form-inline input:focus { outline: 0; border-color: var(--tint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint) 25%, transparent); }
.form-inline { flex-direction: row; }
.form-inline input { flex: 1; min-width: 0; }
.form-error { color: var(--danger); font-size: 15px; font-weight: 500; margin: 8px 0; }
.form-status { font-size: 14px; color: var(--in); font-weight: 600; }

/* ------------------------------------------------------------- Scan -- */
.scan { padding-top: 12px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--label-3); font-family: var(--type); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; margin: 18px 0 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--separator); }
.results { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.result {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px;
  padding: 10px 12px; border: 1px solid var(--separator); border-radius: 12px; text-align: left;
  background: var(--card); color: inherit;
  transition: transform .3s var(--spring);
}
.result:active { transform: scale(.98); }
.result-text { flex: 1; min-width: 0; }
.result-title { display: block; font-weight: 600; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.result-sub { display: block; font-size: 13px; color: var(--label-2); }
.result-tag { display: block; font-family: var(--type); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--in); }
.result .icon { color: var(--label-3); }
.working { text-align: center; padding: 20px 0; }
.working-photo { width: 150px; margin: 0 auto 16px; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow-cover); }
.working-photo img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.working-text { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--separator); border-top-color: var(--tint); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.confirm-card { display: flex; gap: 16px; align-items: center; box-shadow: none; border: 1px solid var(--separator); background: var(--bg); }
.confirm-card .cover { width: 88px; flex: 0 0 auto; }
.confirm-card-mini .cover { width: 52px; }
.confirm-text { flex: 1; min-width: 0; }
.confirm-title { font-family: var(--serif); font-size: 20px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.confirm-card-mini .confirm-title { font-size: 17px; }
.confirm-sub { color: var(--label-2); font-size: 15px; margin-top: 2px; }
.confirm-note { font-family: var(--type); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin-top: 8px; color: var(--in); font-weight: 700; }
.confirm-note.is-warn { color: var(--label-2); text-transform: none; letter-spacing: 0; font-family: var(--font); font-size: 13px; font-weight: 500; }
.alts { margin: 8px 0 16px; }
.not-it { text-align: center; margin: -4px 0 8px; }
.not-it .link { font-size: 15px; }
.actions-stack { flex-direction: column; margin: 8px 0 0; }
.btn .ic { display: none; line-height: 0; }
.btn[data-intent="left"] .ic-left, .btn[data-intent="took"] .ic-took { display: inline-flex; }
@media (min-width: 560px) { .actions-stack { flex-direction: column; } .actions-stack .btn { width: 100%; } }
.done { text-align: center; padding: 8px 0; }
/* The moment it counts: the stamp comes down. */
.done-stamp {
  display: inline-block; margin: 10px 0 16px; padding: 10px 18px 7px;
  border: 3px solid currentColor; border-radius: 8px;
  font-family: var(--type); font-weight: 700; font-size: 22px; line-height: 1.15; letter-spacing: .1em; text-transform: uppercase;
  transform: rotate(-4deg);
  animation: stamp-down .5s var(--ease) both;
}
.done-stamp small { display: block; font-size: 13px; letter-spacing: .14em; }
.done-stamp.is-in { color: var(--in); }
.done-stamp.is-out { color: var(--out); }
@keyframes stamp-down { 0% { transform: rotate(-12deg) scale(2.2); opacity: 0; } 60% { transform: rotate(-4deg) scale(.94); opacity: 1; } 100% { transform: rotate(-4deg) scale(1); } }
.done .confirm-card { text-align: left; }

/* ------------------------------------------------------------ Sheets -- */
.sheet-scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); animation: fade .25s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 560px; margin: 0 auto;
  background: var(--card); color: var(--label);
  border-radius: 22px 22px 0 0;
  padding: 8px 20px max(20px, env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
  animation: sheet-up .5s var(--spring);
  display: flex; flex-direction: column; gap: 10px;
}
@keyframes sheet-up { from { transform: translateY(50%); opacity: .5; } }
.sheet-scan { max-height: min(92vh, 92dvh); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-scan .confirm-card { margin-bottom: 8px; }
.sheet-scan .working { padding: 6px 0 12px; }
.sheet-scan .done { padding: 0; }
.sheet-scan .form { gap: 10px; }
.sheet-scan .actions { margin-bottom: 4px; }
.sheet-scan .alts { margin-bottom: 8px; }
.sheet-scan .search-field { background: var(--bg); }
.sheet-scan .results { max-height: 46vh; overflow-y: auto; margin: 8px -4px; padding: 2px 4px; }
.check { margin: 0 0 6px; padding: 10px 14px; border-radius: 12px; background: var(--tint-soft); color: var(--on-tint-soft); font-size: 15px; }
.check strong { display: block; margin-top: 2px; color: inherit; }
.retake { width: 100%; }
@media (min-width: 600px) { .sheet { bottom: 24px; border-radius: 22px; } }
.sheet-grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--separator); margin: 0 auto 6px; flex: 0 0 auto; }
.sheet-x { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--label) 8%, transparent); color: var(--label-2); display: inline-flex; align-items: center; justify-content: center; }
.sheet h2 { font-family: var(--serif); font-size: 23px; margin: 6px 44px 0 0; }
.sheet h2:focus { outline: none; }
.sheet-p { color: var(--label-2); font-size: 15px; }
.ios-steps { list-style: none; padding: 0; margin: 4px 0 8px; display: flex; flex-direction: column; gap: 10px; }
.ios-steps li { display: flex; align-items: center; gap: 10px; }
.ios-steps li span { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; background: var(--tint-soft); color: var(--on-tint-soft); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.ios-steps .icon { vertical-align: -3px; color: var(--tint); }

/* ------------------------------------------------------------- Toast -- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 8px); z-index: 50;
  transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 999px;
  background: var(--label); color: var(--bg); font-weight: 600; font-size: 15px;
  box-shadow: var(--shadow-float);
  animation: toast-in .4s var(--spring);
}
@keyframes toast-in { from { transform: translate(-50%, 20px); opacity: 0; } }

/* -------------------------------------------------------------- Admin -- */
.admin-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-top: 4px; }
.copies { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--label-2); }
.copies b { min-width: 16px; text-align: center; color: var(--label); }
.edit-form { margin-top: 10px; }

/* ------------------------------------------------------------- Footer -- */
.foot { max-width: var(--maxw); margin: 28px auto 0; padding: 16px; color: var(--label-3); font-size: 13px; text-align: center; }
.foot a { color: var(--label-2); display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 4px; }
.wrap > .footnote a { display: inline-flex; align-items: center; min-height: 44px; }

/* ------------------------------------------------------- Accessibility -- */
@media (prefers-reduced-transparency: reduce) {
  .topbar, .tabbar-pill { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .topbar { background: var(--bg); }
  .tabbar-pill { background: var(--card); }
}
@media (prefers-contrast: more) {
  :root { --label-2: #33383a; --label-3: #4a4d4a; --separator: rgba(29, 35, 39, .45); --rule: #5d8296; }
  .topbar { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; border-bottom-color: var(--label-2); }
  .tabbar-pill { background: var(--card); border-color: var(--label-2); }
  .card, .list, .verb, .libcard { box-shadow: none; border: 1px solid var(--label-2); }
  .stamp, .status-stamp, .done-stamp { opacity: 1; transform: none; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --label-2: #d6d2c4; --label-3: #c2beb0; --separator: rgba(239, 233, 218, .45); --rule: rgba(160, 200, 220, .6); }
}
@media print { .topbar, .tabbar, .foot, .verbs { display: none; } body { padding: 0; } }

/* Admin: a book's cover panel */
.row-flag { font-size: 13px; font-weight: 600; margin-top: 4px; }
.row-flag-warn { color: var(--label-2); font-style: italic; }
.cover-panel { margin-top: 10px; padding-top: 10px; border-top: .5px solid var(--separator); display: flex; flex-direction: column; gap: 10px; }
.cover-panel-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cover-panel-actions .btn { min-height: 44px; }
.cover-opts { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.cover-opt { flex: none; border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--label-3); cursor: pointer; min-width: 60px; min-height: 44px; }
.cover-opt img { width: 60px; height: 90px; object-fit: cover; border-radius: var(--r-cover); box-shadow: var(--shadow-cover); background: var(--card-soft); }
.cover-panel .form-inline { margin: 0; }
.cover-panel .form-inline input { min-width: 0; }
.cover-panel > .link { justify-content: flex-start; }
