/*
 * Bibliophiled: the app.
 *
 * The design system is DESIGN.md: warm paper, deep forest green, a little
 * antique brass, a book serif for titles and the system sans for everything
 * else. The public site (site/site.css) defines the same tokens with the same
 * values, so the landing page and the app are one product.
 *
 * Phone first. One column that widens its grid on a larger screen. Anything a
 * thumb has to hit is at least 44px, and the screens that get repeated work
 * (confirming books, re-shooting an area) keep their actions pinned to the
 * bottom where a thumb already is.
 *
 * Type and space before boxes: sections are a heading, content and room to
 * breathe. A bordered surface is kept for things you act on as a unit - a book
 * to confirm, an unread area, a price to choose, a sheet.
 */

:root {
  color-scheme: light dark;

  --paper: #F6F2E9;
  --paper-deep: #EEE6D4;
  --surface: #FFFCF5;
  --ink: #24291E;
  --ink-soft: #4F564F;
  --ink-faint: #63675E;
  --line: #E2D8C5;
  --line-strong: #CDBFA4;
  --forest: #2C4232;
  --forest-deep: #22301F;
  --forest-soft: #E3E8DC;
  --on-forest: #FFFCF5;
  --brass: #9A6E36;
  --brass-ink: #7B5627;
  --brass-soft: #F1E7D0;
  --wood: #6B4423;
  --warn: #9C5A10;
  --warn-soft: #F8ECD8;
  --danger: #993326;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-book: 3px;
  --shadow-book: 0 1px 1px rgba(40, 30, 15, .10), 0 8px 18px -6px rgba(40, 30, 15, .30);
  --shadow-lift: 0 2px 6px rgba(40, 30, 15, .10), 0 18px 40px -12px rgba(40, 30, 15, .28);
  --ring: 0 0 0 3px color-mix(in srgb, var(--forest) 24%, transparent);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  --gutter: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111613;
    --paper-deep: #161D19;
    --surface: #1B231E;
    --ink: #EEE7D8;
    --ink-soft: #BBB6A8;
    --ink-faint: #8F9288;
    --line: #29322C;
    --line-strong: #3A463F;
    --forest: #A6C49D;
    --forest-deep: #BCD6B3;
    --forest-soft: #1D2B23;
    --on-forest: #0D1811;
    --brass: #C9A06A;
    --brass-ink: #D9B47A;
    --brass-soft: #2A2519;
    --wood: #9B6E4B;
    --warn: #DDA45E;
    --warn-soft: #30281B;
    --danger: #E58C7E;
    --shadow-book: 0 1px 1px rgba(0, 0, 0, .45), 0 10px 22px -8px rgba(0, 0, 0, .8);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .5), 0 18px 40px -12px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { overscroll-behavior-y: none; }

a { color: var(--forest); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }

@media (min-width: 768px) { :root { --gutter: 28px; } }
@media (min-width: 1200px) { :root { --gutter: 40px; } }

.app {
  max-width: calc(720px + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter) calc(104px + var(--safe-bottom));
}
/* The library is a grid of covers and earns the width; reading screens stay at
   a comfortable measure. */
@media (min-width: 1024px) {
  .app:has(#results) { max-width: calc(1120px + 2 * var(--gutter)); }
}

/* ----------------------------------------------------------------- header -- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 calc(-1 * var(--gutter));
  padding: calc(14px + env(safe-area-inset-top, 0px)) var(--gutter) 12px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }

h1.title {
  flex: 1;
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -.015em;
}
h1.title:empty { display: none; }
@media (min-width: 768px) {
  h1.title { font-size: 38px; }
  .topbar { padding-top: 28px; padding-bottom: 14px; }
}

.topbar .subtle { margin-top: 6px; font-size: 15px; max-width: 46ch; }
/* A screen whose title is its content (a book, a message) keeps only Back. */
.topbar:has(h1.title:empty) { padding-bottom: 2px; }
.topbar:has(h1.title:empty) .topbar-row { display: none; }

/* A control a screen hides stays hidden, whatever display its class sets. */
.app [hidden] { display: none !important; }

.back {
  appearance: none;
  display: inline-flex; align-items: center; gap: 2px;
  border: 0; background: none;
  color: var(--forest);
  font: inherit; font-size: 15.5px; font-weight: 500;
  padding: 8px 10px 8px 0;
  margin-left: -6px;
  min-height: 44px;
  cursor: pointer;
}
.back svg { width: 22px; height: 22px; flex: none; }
.back:hover { text-decoration: underline; }

/* A section is a heading, not a box around one. */
h2.section {
  display: flex; align-items: baseline; gap: 10px;
  margin: 36px 0 10px;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -.005em;
}
h2.section .n {
  font-family: var(--sans);
  font-size: 13px; font-weight: 600;
  color: var(--brass-ink);
  font-variant-numeric: tabular-nums;
}

/* The small brass label that introduces a group of things. */
.eyebrow, .control > label, .filter-bar .head span, .facet h3 {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brass-ink);
}
.eyebrow { display: block; margin: 0 0 6px; }

.subtle { color: var(--ink-soft); font-size: 14.5px; line-height: 1.5; margin: 4px 0 0; }
.muted { color: var(--ink-faint); }
.lede { color: var(--ink-soft); font-size: 17px; line-height: 1.55; }
.center { text-align: center; }
.fine { font-size: 13px; }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ------------------------------------------------------------------ input -- */

/*
 * Every text-entry type, not just `text`, at 16px. iOS ZOOMS THE PAGE when a
 * field smaller than 16px is focused; caught in the Simulator, where focusing
 * the password field pushed the Sign in button off the screen.
 */
input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="number"], input[type="tel"], input[type="url"],
textarea, select {
  appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); opacity: 1; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--forest); box-shadow: var(--ring);
}
label.field { display: block; margin: 16px 0 0; }
label.field > span { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; color: var(--ink-soft); }
label.field > span i { font-style: normal; font-weight: 400; color: var(--ink-faint); }

input.search {
  margin-top: 8px;
  padding-left: 44px;
  border-color: transparent;
  background: var(--surface) no-repeat 15px center / 18px 18px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237A6232' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4 4'/%3E%3C/svg%3E");
  box-shadow: inset 0 0 0 1px var(--line);
}
input.search:focus { box-shadow: inset 0 0 0 1px var(--forest), var(--ring); }

/* --------------------------------------------------------------- buttons -- */

button, .btn { font: inherit; cursor: pointer; }

.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 16px; font-weight: 600;
  text-decoration: none;
  transition: transform .08s ease, background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover:not(:disabled) { border-color: var(--ink-faint); }
.btn:active:not(:disabled) { transform: scale(.985); }
.btn.primary { background: var(--forest); border-color: var(--forest); color: var(--on-forest); }
.btn.primary:hover:not(:disabled) { background: var(--forest-deep); border-color: var(--forest-deep); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--forest); }
.btn.quiet:hover:not(:disabled) { border-color: transparent; text-decoration: underline; }
.btn.danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn.danger:hover:not(:disabled) { border-color: transparent; text-decoration: underline; }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 8px 15px; font-size: 14.5px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg, .btn .ico { width: 20px; height: 20px; flex: none; }

.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row > .btn { flex: 1; padding-left: 14px; padding-right: 14px; }
.btn-row.stack { flex-direction: column; }
.btn-row.tight { margin-top: 10px; }

/* Actions a thumb reaches for repeatedly live at the bottom of the screen. */
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  padding: 12px var(--gutter) calc(12px + var(--safe-bottom));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid var(--line);
}
.dock-inner { max-width: 720px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.dock-inner > .btn { flex: 1; }
.dock-inner > p { flex-basis: 100%; margin: 0; }
/* A choice with a quiet second option ("Skip", "Not now") stacks, the main
   action on top, rather than squeezing both onto one line. */
.dock-inner:has(> .btn.quiet) { flex-direction: column; align-items: stretch; gap: 2px; }
.dock-inner:has(> .btn.quiet) > .btn { flex: none; }
@media (max-width: 360px) { .dock-inner > .btn { padding-left: 12px; padding-right: 12px; font-size: 15px; } }

.fab {
  position: fixed;
  right: max(var(--gutter), calc((100vw - 1120px) / 2));
  bottom: calc(18px + var(--safe-bottom));
  z-index: 30;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 54px;
  padding: 0 24px 0 20px;
  border: 0; border-radius: 999px;
  background: var(--forest);
  color: var(--on-forest);
  font-size: 16px; font-weight: 600; letter-spacing: .01em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .16), 0 14px 30px -12px color-mix(in srgb, var(--forest) 70%, #000);
  transition: transform .12s ease, background-color .15s ease;
}
.fab:hover { background: var(--forest-deep); }
.fab:active { transform: scale(.97); }
.fab:focus-visible { outline-offset: 3px; }
.fab-i { flex: none; width: 21px; height: 21px; }
.fab-i svg { width: 21px; height: 21px; display: block; }
body:has(.tabbar) .fab { bottom: calc(76px + var(--safe-bottom)); }

.icon-btn {
  display: inline-grid; place-items: center;
  min-width: 44px; min-height: 44px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--forest);
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--forest-soft); }

.linkish {
  background: none; border: 0; padding: 6px 0; margin: 0; min-height: 32px;
  color: var(--ink-faint); font: inherit; font-size: 12.5px;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.linkish:hover, .linkish:focus-visible { color: var(--ink); }

/* ------------------------------------------------- sort, filters, chips -- */

/* Search, sort and Filters read as one quiet toolbar. */
.controls { display: flex; gap: 8px; align-items: stretch; margin-top: 8px; }
.control {
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  min-height: 46px; padding-left: 15px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.control:focus-within { box-shadow: inset 0 0 0 1px var(--forest), var(--ring); }
.control > label { flex: none; margin: 0; }
select.sort {
  flex: 1; min-width: 0; min-height: 44px;
  padding: 10px 34px 10px 10px;
  border: 0; border-radius: 12px;
  background: transparent no-repeat;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
                    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-size: 5px 5px, 5px 5px;
  background-position: right 17px center, right 12px center;
  font-size: 15px; font-weight: 500;
}
select.sort:focus { box-shadow: none; }

.filter-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 0 16px 0 14px;
  border: 0; border-radius: 12px;
  background: var(--surface); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 15px; font-weight: 500; white-space: nowrap;
}
.filter-btn svg { width: 17px; height: 17px; flex: none; color: var(--brass-ink); }
.filter-btn.on { background: var(--forest-soft); color: var(--forest); box-shadow: inset 0 0 0 1px var(--forest); font-weight: 600; }
.filter-btn i {
  font-style: normal; font-size: 11.5px; font-weight: 700;
  background: var(--forest); color: var(--on-forest);
  border-radius: 999px; padding: 1px 7px;
}

/* On a wide screen search, sort and Filters share one row. */
@media (min-width: 768px) {
  .app:has(#results) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
    align-content: start;
  }
  .app:has(#results) > * { grid-column: 1 / -1; }
  .app:has(#results) > input.search { grid-column: 1; }
  .app:has(#results) > .controls { grid-column: 2; }
  .app:has(#results) .control { min-width: 240px; }
}

.filter-bar { margin-top: 18px; }
.filter-bar .head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.filter-bar .clear {
  appearance: none; border: 0; background: none;
  color: var(--forest); font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 6px 0; min-height: 32px;
}

.chips {
  display: flex; gap: 8px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--gutter)); padding: 10px var(--gutter) 2px;
}
.chips::-webkit-scrollbar { display: none; }
/* Genre chips wrap instead of scrolling: a clipped row hides options and reads
   as an accident on a phone. */
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 10px 0 0; gap: 7px; }
.chip {
  flex: none;
  appearance: none;
  min-height: 36px;
  padding: 6px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink-soft);
  font: inherit; font-size: 14px; font-weight: 500;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--forest); color: var(--on-forest); }
.chip.more { background: transparent; color: var(--forest); font-weight: 600; }

/* -------------------------------------------------------------- library -- */

/* The count above the grid is a caption, not a sentence. */
#results > .subtle, .count-line {
  margin-top: 20px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 26px 12px;
  margin-top: 16px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 34px 22px; } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 40px 28px; } }

.tile {
  display: block; width: 100%;
  border: 0; padding: 0; margin: 0;
  background: none; color: inherit; text-align: left;
  cursor: pointer; border-radius: 4px;
}
.tile .cover-wrap { position: relative; border-radius: var(--radius-book); transition: transform .18s ease; }
/* A faint hinge down the left edge, so every cover sits on the shelf as the
   same kind of object. */
.tile .cover-wrap::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, .10) 0, rgba(255, 255, 255, .10) 3%, rgba(0, 0, 0, .06) 5%, transparent 8%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .07);
}
@media (hover: hover) { .tile:hover .cover-wrap { transform: translateY(-3px); } }
.tile:focus-visible { outline-offset: 5px; }
.tile .t {
  margin: 12px 0 0;
  font-family: var(--serif); font-size: 15px; font-weight: 600; line-height: 1.25;
  color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile .a {
  margin: 3px 0 0;
  font-size: 12.5px; line-height: 1.35; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (min-width: 1024px) { .tile .t { font-size: 16px; } .tile .a { font-size: 13px; } }

.cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-book);
  background: var(--paper-deep);
  box-shadow: var(--shadow-book);
}
.copies-badge {
  position: absolute; top: 7px; right: 7px; z-index: 1;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(20, 26, 22, .84); color: #F6F2E9;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em; line-height: 1.3;
}

/*
 * A book with no picture: an unprinted clothbound book. One binding colour for
 * every book, so the colour never suggests something about the edition, with a
 * blind-stamped frame and the title in the serif. Nothing is invented; it shows
 * only what we know.
 */
.cover.placeholder {
  --cloth: #2F4A3B;
  position: relative;
  display: flex; flex-direction: column; justify-content: flex-start; gap: 6px;
  padding: 18px 12px 12px 19px;
  overflow: hidden;
  font-family: var(--serif); font-size: 14px; line-height: 1.22;
  color: #F1E9D8;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .24) 0 5px, rgba(255, 255, 255, .07) 5px 6px, transparent 6px),
    linear-gradient(165deg, rgba(255, 255, 255, .07), rgba(0, 0, 0, .14)),
    var(--cloth);
}
.cover.placeholder::before {
  content: ''; position: absolute; pointer-events: none;
  left: 11px; right: 6px; top: 6px; bottom: 6px;
  border: 1px solid rgba(222, 196, 128, .32);
  border-radius: 1px;
}
.cover.placeholder .ph-title {
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
  font-weight: 600;
}
.cover.placeholder .ph-author {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-family: var(--sans); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: rgba(241, 233, 216, .74);
}
.cover.placeholder .ph-mark { display: none; }
.row .cover.placeholder, .hit .cover.placeholder {
  gap: 3px; padding: 7px 5px 6px 10px; font-size: 9.5px; box-shadow: none;
}
.row .cover.placeholder::before, .hit .cover.placeholder::before { left: 7px; right: 3px; top: 3px; bottom: 3px; }
.row .cover.placeholder .ph-author, .hit .cover.placeholder .ph-author { display: none; }
.rec-cover .cover.placeholder { padding: 10px 7px 8px 13px; font-size: 11px; }
.rec-cover .cover.placeholder .ph-author { font-size: 9px; }

/* ----------------------------------------------------------- book detail -- */

/* The book, centred on a parchment band: the cover is the picture. */
.detail-head {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  margin: 0 calc(-1 * var(--gutter));
  padding: 18px var(--gutter) 26px;
  background: linear-gradient(to bottom, var(--paper-deep), var(--paper));
}
.detail-head .cover { width: 148px; flex: none; }
.detail-head .cover.placeholder { font-size: 16px; padding: 22px 14px 16px 22px; }
.detail-head h1 {
  margin: 20px 0 4px;
  font-family: var(--serif); font-size: 27px; line-height: 1.15; font-weight: 600; letter-spacing: -.015em;
  max-width: 22ch;
}
.detail-head .subtle { max-width: 34ch; margin: 0 auto; }
.detail-head .a { margin: 8px 0 0; font-size: 15.5px; color: var(--ink-soft); }
@media (min-width: 640px) {
  .detail-head { flex-direction: row; align-items: flex-end; text-align: left; gap: 26px; padding: 24px var(--gutter) 28px; }
  .detail-head .cover { width: 168px; }
  .detail-head h1 { margin-top: 0; font-size: 32px; }
  .detail-head .subtle { margin: 0; }
}

.facts { margin: 6px 0 0; }
.fact { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.fact:last-child { border-bottom: 0; }
.fact dt { flex: none; width: 104px; color: var(--ink-faint); margin: 0; }
.fact dd { flex: 1; min-width: 0; margin: 0; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { background: var(--forest-soft); color: var(--ink); border-radius: 999px; padding: 4px 11px; font-size: 13px; }

.stars { display: flex; align-items: center; gap: 2px; }
.star {
  appearance: none; border: 0; background: none;
  padding: 6px 3px; min-height: 44px;
  font-size: 28px; line-height: 1;
  color: var(--line-strong);
}
.star.on { color: var(--brass); }
.stars.readonly .star { cursor: default; }
.stars .btn.quiet { min-height: 40px; padding: 6px 10px; font-size: 14px; }

.kept-line { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--ink-soft); font-size: 14.5px; }
.kept-line svg { width: 16px; height: 16px; flex: none; color: var(--brass-ink); }

.desc { margin-top: 8px; font-size: 15.5px; line-height: 1.65; color: var(--ink-soft); }

.copy-card { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.copy-card:last-of-type { border-bottom: 0; }
.copy-card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.copy-card .head b { font-weight: 600; }

/* A list of things to do with a book: rows, not a stack of bordered buttons. */
.action-list { margin: 32px 0 0; border-top: 1px solid var(--line); }
.action-list .action {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 54px; padding: 12px 2px;
  border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--ink); text-align: left;
  font: inherit; font-size: 16px; font-weight: 500;
}
.action-list .action > svg { width: 20px; height: 20px; flex: none; color: var(--brass-ink); }
.action-list .action .chev { margin-left: auto; color: var(--ink-faint); display: grid; }
.action-list .action .chev svg { width: 18px; height: 18px; }
.action-list .action:hover { color: var(--forest); }
.action-list .action.danger { color: var(--danger); }
.action-list .action.danger > svg { color: var(--danger); }
.provenance { margin: 18px 0 0; font-size: 13px; color: var(--ink-faint); }

/* ---------------------------------------------------------------- notes -- */

/* A note is a margin rule and a tint, never a box. */
.note {
  margin-top: 14px;
  padding: 12px 15px 12px 16px;
  border-left: 3px solid var(--brass);
  border-radius: 0 12px 12px 0;
  background: color-mix(in srgb, var(--brass-soft) 60%, transparent);
  font-size: 14.5px; line-height: 1.5;
}
.note.good { border-left-color: var(--forest); background: var(--forest-soft); }
.note.warn { border-left-color: var(--warn); background: var(--warn-soft); color: var(--ink); }
.note strong, .note b { font-weight: 600; }
.note .btn-row { margin-top: 12px; }
/* Only the running state lays out a spinner beside its words. */
.note.enh:has(> .mini-spinner) { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; }
.note.enh > div:not(.mini-spinner):not(.btn-row) { flex: 1; min-width: 0; }
.note.enh > .btn-row { flex-basis: 100%; }

/* What a scan did, as numbers on the page rather than four little boxes. */
.summary {
  display: flex;
  margin: 10px 0 4px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat { flex: 1; min-width: 0; text-align: center; padding: 0 6px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat .n {
  font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}
.stat .l { margin-top: 8px; font-size: 12.5px; line-height: 1.3; color: var(--ink-soft); }

/* --------------------------------------------------------------- photos -- */

.photo-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 16px; }
.photo-thumb {
  position: relative; aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm); overflow: hidden;
  background: var(--paper-deep);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .x {
  position: absolute; top: 5px; right: 5px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(20, 26, 22, .74); color: #fff;
  font-size: 17px; line-height: 1;
  display: grid; place-items: center;
}
/* An invisible 44px target around the small round button. */
.photo-thumb .x::after { content: ''; position: absolute; inset: -7px; }

.photo-list { display: flex; flex-direction: column; margin-top: 16px; border-top: 1px solid var(--line); }
.photo-row { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.photo-row .photo-thumb { flex: 0 0 88px; margin: 0; }
.photo-row .photo-thumb img { width: 88px; height: 88px; object-fit: cover; }
.photo-row .photo-loc { flex: 1; min-width: 0; margin: 0; }

.loc-all { display: flex; gap: 10px; align-items: flex-end; margin-top: 14px; }
.loc-all .field { flex: 1; margin: 0; }
.loc-all .btn { flex: none; white-space: nowrap; min-height: 48px; }
.loc-hint { margin: 8px 0 12px; }
.loc-teaser { margin: 12px 0; }
.loc-teaser summary { cursor: pointer; color: var(--forest); font-size: 14.5px; font-weight: 500; padding: 10px 0; min-height: 44px; }
.loc-field { margin-top: 12px; }
@media (max-width: 360px) {
  .loc-all { flex-direction: column; align-items: stretch; }
  .loc-all .btn { width: 100%; }
  .photo-row .photo-thumb { flex-basis: 68px; }
  .photo-row .photo-thumb img { width: 68px; height: 68px; }
}

.enh-line { margin: 10px 0 0; font-size: 13.5px; color: var(--ink-soft); }
/* An inline link still gets a thumb-sized target, without moving the text. */
.enh-line a { display: inline-block; padding: 13px 4px; margin: -13px -4px; }

/* ------------------------------------------------------ progress, loading -- */

.progress-wrap { margin: 56px auto 0; max-width: 34ch; text-align: center; }
.progress-wrap h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 24px; font-weight: 600; }
.bar { height: 6px; margin: 26px 0 10px; border-radius: 999px; background: var(--paper-deep); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--forest); transition: width .5s ease; }

.spinner {
  width: 26px; height: 26px; margin: 28px auto 18px;
  border: 2.5px solid var(--line); border-top-color: var(--forest);
  border-radius: 50%; animation: spin .9s linear infinite;
}
.progress-wrap .spinner { margin-top: 0; }
.mini-spinner {
  flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--forest);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: var(--paper-deep); border-radius: var(--radius-sm); animation: pulse 1.4s ease-in-out infinite; }
.skeleton.cover { aspect-ratio: 2 / 3; box-shadow: none; border-radius: var(--radius-book); }
.skeleton.line { height: 12px; margin-top: 10px; }
.skeleton.line.short { width: 60%; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* An empty state: a short brass rule, a serif line, one sentence, one action. */
.empty { padding: 36px 12px 24px; text-align: center; }
/* The logo's divider, small: two hairlines and a brass double chevron. */
.empty::before {
  content: '\00BB'; display: block; width: 116px; margin: 0 auto 16px;
  font-family: var(--serif); font-size: 22px; line-height: 1; text-align: center; color: var(--brass);
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) left center / 42px 1px no-repeat,
    linear-gradient(var(--line-strong), var(--line-strong)) right center / 42px 1px no-repeat;
}
.empty .mark { display: none; }
.empty h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
.empty p { max-width: 34ch; margin: 0 auto 24px; color: var(--ink-soft); font-size: 15.5px; }

/* A first visit, an introduction or a "not yet": a panel with a job to do,
   rather than a heading floating in an empty page. */
.first-run, .intro-panel {
  margin: 14px 0 0;
  padding: 24px 20px 22px;
  border-radius: var(--radius);
  background: linear-gradient(to bottom, var(--paper-deep), color-mix(in srgb, var(--paper-deep) 40%, var(--paper)));
}
.first-run h2, .intro-panel h2 {
  margin: 0 0 6px;
  font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.2;
}
.first-run > p, .intro-panel > p { margin: 0; color: var(--ink-soft); font-size: 15.5px; }
.intro-panel .eyebrow { margin-bottom: 8px; }
.intro-panel .perks { margin: 14px 0 18px; }
.first-run .btn, .first-run .note { margin-top: 20px; }
/* A quiet Premium hint at the end of the library (hints.js): set apart from the
   books by space, not by colour, and quieter than an empty state. */
.intro-panel.hint { margin-top: 36px; padding: 20px 18px 16px; }
.intro-panel.hint h2 { font-size: 20px; }
.intro-panel.hint > p:not(.eyebrow) { font-size: 14.5px; }

.steps { list-style: none; counter-reset: step; margin: 18px 0 0; padding: 0; }
.steps li {
  counter-increment: step;
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 12px 0 12px 44px;
  border-top: 1px solid var(--line);
}
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--forest); color: var(--on-forest);
  font-family: var(--serif); font-size: 16px; font-weight: 600;
}
.steps b { font-size: 16px; }
.steps span { color: var(--ink-soft); font-size: 14.5px; }

.meter { height: 8px; margin: 16px 0 6px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.meter > i { display: block; height: 100%; min-width: 8px; border-radius: 999px; background: var(--brass); }

.scan-tips { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.tip-list { list-style: none; margin: 4px 0 12px; padding: 0; }
.tip-list li { position: relative; padding: 9px 0 9px 22px; color: var(--ink-soft); font-size: 15px; }
.tip-list li::before {
  content: ''; position: absolute; left: 2px; top: 17px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--brass);
}
.tip-list b { color: var(--ink); }

/* --------------------------------------------------------------- results -- */

.enh-tag { margin: 3px 0 0; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; color: var(--brass-ink); }
.enh-tag.inline { display: inline; margin: 0; }
.auto-tile { cursor: pointer; }

/* ------------------------------------------------- confirm, one by one -- */

.row-group { margin-top: 18px; }
.row-group + .row-group { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); }

.row {
  display: flex; align-items: flex-start; gap: 14px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .15s ease, background-color .15s ease;
}
.row .cover { width: 56px; flex: none; box-shadow: 0 1px 3px rgba(40, 30, 15, .2); }
.row .body { flex: 1; min-width: 0; }
.row .t { margin: 0; font-family: var(--serif); font-size: 17px; font-weight: 600; line-height: 1.25; }
.row .a { margin: 3px 0 0; font-size: 14px; color: var(--ink-soft); }
.row .meta { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.row.selectable { cursor: pointer; }
.row.picked { border-color: var(--forest); background: var(--forest-soft); box-shadow: inset 0 0 0 1px var(--forest); }
.row.dimmed { opacity: .5; }

.tick {
  flex: none; display: grid; place-items: center;
  width: 28px; height: 28px; margin-top: 2px;
  border: 2px solid var(--line-strong); border-radius: 50%;
  background: var(--surface);
  color: transparent; font-size: 14px; font-weight: 700;
}
.row.picked .tick { background: var(--forest); border-color: var(--forest); color: var(--on-forest); }

.alt-toggle {
  appearance: none; display: block;
  border: 0; background: none;
  padding: 10px 0 2px; min-height: 44px;
  color: var(--forest); font: inherit; font-size: 14px; font-weight: 500; text-align: left;
}
.alts { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.alt {
  appearance: none; width: 100%; min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper);
  font: inherit; font-size: 14px; text-align: left; color: var(--ink);
}
.alt b { font-weight: 600; }
.alt .a { color: var(--ink-faint); font-size: 12.5px; }

/* ------------------------------------------------------ unread areas ----- */

/*
 * Contextual crops are shown WHOLE: height follows the image's own aspect.
 * A fixed 4:3 box with `object-fit: cover` once cut a tall spine-shaped crop
 * to a band through its middle.
 */
.crop { display: block; width: 100%; height: auto; background: var(--paper-deep); }
.crop-note { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-faint); text-align: center; }

.area-card {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.area-card .body { padding: 14px 16px 16px; }
.area-card h3 { margin: 0 0 4px; font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1.3; }
.area-card .where { margin: 0 0 12px; font-size: 13.5px; color: var(--ink-faint); }
.area-card .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.area-card .actions > .btn { flex: 1 1 46%; min-height: 46px; padding: 10px 14px; font-size: 15px; }
.area-card.done { opacity: .62; }

.disclosure {
  appearance: none; width: 100%; min-height: 44px;
  margin-top: 8px; padding: 12px 0;
  border: 0; background: none;
  color: var(--forest); font: inherit; font-size: 14.5px; font-weight: 500; text-align: left;
}

/* A shelf photo with the areas we could not read drawn on it. */
.shelf { position: relative; margin-top: 12px; border-radius: var(--radius); overflow: hidden; background: var(--paper-deep); line-height: 0; }
.shelf img { width: 100%; height: auto; display: block; }
.region {
  position: absolute; padding: 0;
  border: 2.5px solid var(--warn); border-radius: 7px;
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  cursor: pointer;
}
/* A small area stays the size it really is; its tappable area is grown invisibly. */
.region::after { content: ''; position: absolute; inset: -9px; min-width: 44px; min-height: 44px; }
.region .pin {
  position: absolute; top: -11px; left: -11px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--warn); color: #fff;
  font: 600 13px/24px var(--sans); text-align: center;
}
.region.done { border-color: var(--forest); background: color-mix(in srgb, var(--forest) 14%, transparent); }
.region.done .pin { background: var(--forest); color: var(--on-forest); }

/* The spine being reviewed, above what we think it is: fixed height, natural
   width, centred, so the whole crop is visible. */
.spine-strip { position: relative; margin: 10px 0 0; }
.spine-strip img {
  display: block; margin: 0 auto;
  height: 300px; width: auto; max-width: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--paper-deep);
}
@media (max-height: 700px) { .spine-strip img { height: 220px; } }

/* The outline of the book a close-up is about (app.js#cropMarkSvg), laid over
   the picture's own box and fitted like it. Its colours are FIXED, not themed:
   they sit on photographs, not on paper. */
.marked { position: relative; }
.crop-mark {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; overflow: visible;
}
/* Until the picture is there, there is nothing to outline. */
.spine-strip:not(.loaded) .crop-mark, .marked:not(.loaded) .crop-mark { display: none; }
.crop-mark rect {
  fill: none; stroke: #ffd400; stroke-width: 3;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, .9));
}
/* In an unread area's close-up, the spines this scan already added
   (app.js#areaMarksSvg). Lightly filled as well as green, so "done" does not
   rest on telling green from yellow. */
.crop-mark rect.added {
  stroke: #2fd16b; stroke-width: 2.5; fill: rgba(47, 209, 107, .2);
}
.added-legend {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0 8px; font-size: 13px; color: var(--ink-soft);
}
.added-legend .swatch {
  flex: none; width: 14px; height: 14px; border-radius: 3px;
  border: 2px solid #2fd16b; background: rgba(47, 209, 107, .2);
}

/* -------------------------------------------------------- search sheet -- */

#hits { margin-top: 6px; }
.hit {
  display: flex; gap: 14px; width: 100%; min-height: 80px;
  padding: 12px 2px;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: none; color: inherit; font: inherit; text-align: left;
}
.hit:active { background: var(--paper-deep); }
.hit img, .hit .cover { width: 48px; flex: none; box-shadow: 0 1px 3px rgba(40, 30, 15, .2); }
.hit .info { flex: 1; min-width: 0; }
.hit .t { margin: 0; font-family: var(--serif); font-size: 16px; font-weight: 600; line-height: 1.25; }
.hit .a { margin: 3px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.hit .m { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.hit .owned { color: var(--warn); font-weight: 500; }
.searching { padding: 22px 0; color: var(--ink-faint); font-size: 14.5px; text-align: center; }

/* ---------------------------------------------------------------- sheet -- */

/*
 * The backdrop is OPT IN: not displayed unless `.open` is on it. `hidden` sets
 * `display: none` through the user-agent stylesheet, and any author rule that
 * sets `display` beats it - which once left an invisible backdrop over the
 * whole app, swallowing every tap. tests/overlay.test.ts pins this.
 */
.sheet {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(14, 18, 15, .46);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sheet.open { display: flex; }

/* Belt and braces: a closed sheet can never intercept a tap. */
.sheet:not(.open), .sheet[hidden] {
  display: none;
  pointer-events: none;
}
.sheet-card {
  width: 100%; max-width: 720px; max-height: 90vh;
  overflow-y: auto;
  padding: 10px 20px calc(22px + var(--safe-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lift);
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(18px); opacity: .6; } }
.sheet-grip { width: 38px; height: 4px; margin: 6px auto 16px; border-radius: 999px; background: var(--line-strong); }
.sheet-card h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.25; }
.sheet-card > p:not(.subtle):not(.note) { color: var(--ink-soft); }
.sheet-card ul { margin: 12px 0 0; padding-left: 20px; color: var(--ink-soft); font-size: 14.5px; }
.sheet-card li { margin-bottom: 6px; }
.sheet-actions { margin-top: 6px; }

/* ---------------------------------------------------------------- toast -- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translate(-50%, 14px);
  z-index: 60;
  max-width: calc(100vw - 40px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-size: 14.5px; font-weight: 500; text-align: center;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------- settings -- */

/* Settings are sections separated by a rule, not a column of cards. */
.setting-card { padding: 24px 0; border-top: 1px solid var(--line); }
.topbar + .setting-card, .setting-card:first-child { border-top: 0; padding-top: 12px; }
.setting-row { display: flex; align-items: flex-start; gap: 16px; }
.plan-row .setting-row { align-items: center; }
.setting-text { flex: 1; min-width: 0; }
.setting-text h2 { margin: 0 0 4px; font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.3; }
.setting-text p { margin: 0; color: var(--ink-soft); font-size: 15px; }
.setting-state { margin: 12px 0 0; font-size: 14.5px; color: var(--ink-soft); }
.setting-state b { color: var(--ink); }
.setting-card a { color: var(--forest); }
.setting-card.dev { border-top-style: dashed; }
.setting-card > h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 20px; font-weight: 600; }

.dev-tag, .plan-tag {
  display: inline-block; margin-left: 6px; padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--sans); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  vertical-align: 3px;
}
.dev-tag { color: var(--warn); background: var(--warn-soft); }
.plan-tag { color: var(--brass-ink); background: var(--brass-soft); }

/* An accessible switch: role=switch plus aria-checked is the state. */
.switch {
  flex: none; position: relative;
  width: 54px; height: 32px; margin-top: 2px;
  border: 0; border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer; transition: background-color .15s ease;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .15s ease;
}
.switch[aria-checked="true"] { background: var(--forest); }
.switch[aria-checked="true"] .knob { transform: translateX(22px); }
/* The visible switch is 32px tall; its hit area is 46px. */
.switch::after { content: ''; position: absolute; inset: -7px; }
.switch:disabled { opacity: .45; cursor: default; }

.privacy { margin-top: 14px; }
.privacy summary {
  display: flex; align-items: center; min-height: 44px;
  cursor: pointer; color: var(--forest); font-size: 14.5px; font-weight: 600;
}
.privacy ul { margin: 4px 0 0; padding-left: 18px; font-size: 14px; color: var(--ink-soft); }
.privacy li { margin: 8px 0; }
.privacy b { color: var(--ink); font-weight: 600; }

/* Delete account: tucked behind its own disclosure, in the danger colour. */
details.danger { margin-top: 10px; }
details.danger summary {
  display: flex; align-items: center; min-height: 44px;
  cursor: pointer; color: var(--danger); font-size: 14.5px; font-weight: 600;
}
details.danger p { margin: 4px 0 12px; font-size: 14px; color: var(--ink-soft); }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14.5px; }

.seg {
  display: flex; gap: 3px; margin-top: 12px; padding: 3px;
  border-radius: 999px; background: var(--paper-deep);
}
.seg button {
  flex: 1; min-height: 42px; padding: 10px 8px;
  border: 0; border-radius: 999px;
  background: none; color: var(--ink-soft);
  font: inherit; font-size: 15px; font-weight: 500;
}
.seg button.on { background: var(--forest); color: var(--on-forest); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .14); }

.site-links { margin: 36px 0 0; text-align: center; font-size: 13.5px; color: var(--ink-faint); }
.site-links a { display: inline-block; padding: 10px 6px; color: var(--ink-soft); }

/* --------------------------------------------------- the signed-out gate -- */

.gate { padding: 4vh 4px 0; text-align: center; }
.wordmark {
  margin: 0;
  font-family: var(--serif); font-size: 44px; font-weight: 600; line-height: 1.05; letter-spacing: -.02em;
}
.gate .eyebrow { margin-top: 28px; }
.gate .lede { max-width: 26em; margin: 0 auto 28px; }
.gate .btn-row { max-width: 360px; margin: 0 auto; }
.gate-foot { margin-top: 30px; }
.gate-foot a { display: inline-block; padding: 10px 4px; color: var(--ink-soft); }

/* The full logo, as supplied, on the paper colour it was drawn on. */
.brand-logo { display: block; width: min(78vw, 300px); margin: 0 auto 4px; }
.brand-logo img { display: block; width: 100%; height: auto;
  /* The artwork's own paper fades into the page at its outer margin, which
     holds no drawing (the arch and the wordmark start well inside it). */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent),
                      linear-gradient(to bottom, transparent, #000 2.5%, #000 97%, transparent);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent),
                      linear-gradient(to bottom, transparent, #000 2.5%, #000 97%, transparent);
          mask-composite: intersect;
}

.auth-form { margin-top: 8px; }
.auth-form > .btn { margin-top: 22px; }
.auth-form .note { margin-top: 16px; }
.field-foot { display: flex; justify-content: flex-end; margin-top: 2px; }
.field-foot a, .text-link {
  display: inline-block; padding: 10px 0;
  color: var(--forest); font-size: 14.5px; font-weight: 500; text-decoration: none;
}
.field-foot a:hover, .text-link:hover { text-decoration: underline; }
.auth-alt { margin-top: 26px; text-align: center; color: var(--ink-soft); font-size: 15px; }
.auth-alt a { font-weight: 600; }
.done-mark {
  display: grid; place-items: center;
  width: 56px; height: 56px; margin: 28px auto 6px;
  border-radius: 50%; background: var(--forest-soft); color: var(--forest);
}
.done-mark svg { width: 28px; height: 28px; }
.done-mark + .empty::before { display: none; }

/* ----------------------------------------------------------- onboarding -- */

.dots { display: flex; justify-content: center; gap: 6px; margin: 4px 0 20px; }
.dots i { width: 22px; height: 3px; border-radius: 2px; background: var(--line); }
.dots i.on { background: var(--forest); }

.plan-card { margin-bottom: 18px; padding: 18px 0 4px; border-top: 1px solid var(--line); }
.plan-card.premium {
  padding: 18px 18px 8px;
  border-top: 3px solid var(--forest);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
}
.plan-card h2 {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 8px;
  font-family: var(--serif); font-size: 21px; font-weight: 600;
}
.plan-card h2 .p { font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--forest); }

.perk-list { list-style: none; margin: 0; padding: 0; }
.perk-list li { position: relative; padding: 7px 0 7px 26px; color: var(--ink-soft); font-size: 15.5px; }
.perk-list li::before {
  content: ''; position: absolute; left: 2px; top: 13px;
  width: 11px; height: 6px;
  border-left: 2px solid var(--forest); border-bottom: 2px solid var(--forest);
  transform: rotate(-45deg);
}
.perk-list li.on { color: var(--ink); font-weight: 600; }

/* --------------------------------------------------------------- premium -- */

.perks { margin: 18px 0 26px; }
.perk { display: flex; flex-direction: column; gap: 2px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.perk:last-child { border-bottom: 0; }
.perk b { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.perk span { color: var(--ink-soft); font-size: 14.5px; }

.price-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0 20px; }
.price-opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 104px; padding: 16px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit;
}
.price-opt:first-child { border-color: var(--forest); box-shadow: inset 0 0 0 1px var(--forest); }
.price-opt .lab { font-size: 11.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--brass-ink); }
.price-opt .amt { font-family: var(--serif); font-size: 28px; font-weight: 600; }
.price-opt .per { font-size: 12.5px; color: var(--ink-soft); text-align: center; }
.price-line { color: var(--ink-soft); }

/* One row in place of a Premium control. Not a banner, not a modal. */
.locked {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 60px; margin: 12px 0; padding: 14px 16px;
  border: 0; border-radius: 14px;
  background: var(--brass-soft);
  color: var(--ink); font: inherit; text-align: left;
  cursor: pointer;
}
.locked .lock { display: grid; place-items: center; flex: none; color: var(--brass-ink); }
.locked .lock svg { width: 18px; height: 18px; }
.locked-text { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.locked-text b { font-size: 15px; }
.locked-text span { color: var(--ink-soft); font-size: 13.5px; }
.locked .chev { color: var(--brass-ink); font-size: 22px; }

/* --------------------------------------------------------------- filters -- */

.filter-body { max-height: 58vh; overflow-y: auto; margin: 0 -2px; padding: 0 2px; }
.facet { margin-bottom: 20px; }
.facet h3 { margin: 0 0 8px; }
.facet .chip i { margin-left: 3px; font-style: normal; font-size: 12px; color: var(--ink-faint); }
.facet .chip[aria-pressed="true"] i { color: inherit; opacity: .75; }
.year-row { display: flex; gap: 12px; }
.field.inline { flex: 1; margin: 0; }

/* -------------------------------------------------------- recommendations -- */

.rec-basis { margin: 12px 0 4px; font-size: 13.5px; }
.rec-list { display: flex; flex-direction: column; margin-top: 8px; }
.rec { display: flex; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.rec:last-child { border-bottom: 0; }
.rec-cover { flex: 0 0 78px; }
.rec-cover .cover { width: 78px; height: 117px; object-fit: cover; }
.rec-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rec-body .t { margin: 0; font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1.25; }
.rec-body .a { margin: 0; color: var(--ink-soft); font-size: 14px; }
.rec-body .why {
  align-self: flex-start;
  margin: 8px 0 0; padding: 0 0 0 10px;
  border-left: 2px solid var(--brass);
  font-family: var(--serif); font-style: italic; font-size: 14.5px; color: var(--ink-soft);
}
.rec-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
@media (max-width: 380px) {
  .rec { gap: 12px; }
  .rec-cover { flex-basis: 62px; }
  .rec-cover .cover { width: 62px; height: 93px; }
}

/* ------------------------------------------------------ bottom navigation -- */

/* Only on the three top-level screens. The app pads its own bottom for it. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center;
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative;
  flex: 1 1 0; max-width: 168px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 58px; padding: 8px 4px;
  border: 0; background: none;
  color: var(--ink-faint);
  font: inherit; font-size: 11px; font-weight: 500; letter-spacing: .02em;
  transition: color .15s ease;
}
.tab .i { display: block; width: 24px; height: 24px; }
.tab .i svg { width: 24px; height: 24px; display: block; }
.tab:hover { color: var(--ink-soft); }
.tab.on { color: var(--forest); }
.tab.on .l { font-weight: 650; }
.tab.on::before {
  content: ''; position: absolute; top: -1px; left: 50%;
  width: 28px; height: 2px; margin-left: -14px;
  border-radius: 0 0 2px 2px; background: var(--forest);
}
.tab:focus-visible { outline-offset: -5px; border-radius: 12px; }
.app:has(.tabbar) { padding-bottom: calc(150px + var(--safe-bottom)); }

/* ---------------------------------------------------------------- motion -- */

@media (prefers-reduced-motion: reduce) {
  .spinner, .mini-spinner, .skeleton, .sheet-card { animation: none; }
  .bar > i, .tile .cover-wrap, .fab, .btn, .chip, .tab, .switch, .switch .knob, .toast { transition: none; }
  .tile:hover .cover-wrap { transform: none; }
}
