/* Book Chronicles 0.2.0: Bookcloth & Foil (DESIGN.md). Every book is a bound
   volume; the shell is bottle-green cloth on an endpaper ground; foil marks
   only the primary action, the current page and the Finished state. */

@font-face {
  font-family: "Jost";
  src: url("fonts/jost-1-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Jost";
  src: url("fonts/jost-1-latin-ext.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;

  /* Endpaper ground and ink */
  --ground: #eef1ec;
  --surface: #ffffff;
  --surface-sunk: #e2e7e1;
  --ink: #17211c;
  --ink-soft: #46524c;
  --line: #cdd5ce;
  --line-strong: #7a8780;
  --link: #22543f;
  --error: #a4262c;
  --error-ground: #fbecec;
  --notice-ground: #e4efe8;
  --focus: #2f62c4;

  /* Shell cloth and foil */
  --cloth: #1f3d33;
  --cloth-deep: #16302a;
  --cloth-ink: #e7eee9;
  --cloth-ink-soft: #b9cbc1;
  --cloth-ink-hover: #ffffff;
  --foil: #d9b44a;
  --foil-ink: #1d1a0f;
  --foil-hover: #e6c463;

  /* Buttons */
  --primary: #1f3d33;
  --primary-hover: #2a5244;
  --primary-ink: #ffffff;

  /* One colour per reading status, always shown with its label */
  --st-want: #2b4a7a;
  --st-reading: #1f7259;
  --st-finished: #8a6414;
  --st-abandoned: #66706b;

  /* Bookcloth for books without a cover; the colour carries no meaning */
  --cloth-1: #6b2230;
  --cloth-2: #22345c;
  --cloth-3: #24493b;
  --cloth-4: #5e4220;
  --cloth-5: #4e2c4f;
  --cloth-6: #34434f;
  --cloth-7: #1e4f55;
  --cloth-8: #7a3420;

  --radius: 6px;
  --radius-card: 12px;
  --display: "Jost", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  /* Phones (393-440px wide) get one column; desktop pages use --wide. */
  --measure: 40rem;
  --wide: 90rem;
  --gutter: 1rem;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ground: #111915;
    --surface: #18221d;
    --surface-sunk: #0c130f;
    --ink: #e4ebe6;
    --ink-soft: #a9b7af;
    --line: #2c3a33;
    --line-strong: #74847b;
    --link: #9fd1b8;
    --error: #ff9a94;
    --error-ground: #351b1b;
    --notice-ground: #1c2e25;
    --focus: #8fb4ff;
    --cloth: #193229;
    --cloth-deep: #0f211b;
    --primary: #2e5a49;
    --primary-hover: #3a6d59;
    --st-want: #93b3e8;
    --st-reading: #6fcfae;
    --st-finished: #e2bb5c;
    --st-abandoned: #a1aca6;
  }
}

@media (min-width: 48rem) {
  :root {
    --gutter: 2rem;
  }
}

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

body {
  display: flex;
  flex-direction: column;
  min-block-size: 100vh;
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  accent-color: var(--primary);
  caret-color: var(--link);
  scrollbar-color: var(--line-strong) transparent;
  -webkit-text-size-adjust: 100%;
}

::selection {
  background: color-mix(in srgb, var(--foil) 45%, transparent);
  color: var(--ink);
}

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

a:hover {
  text-decoration-thickness: 2px;
}

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

.skip-link {
  position: absolute;
  z-index: 10;
  inset-inline-start: 1rem;
  inset-block-start: -3rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--link);
  border-radius: var(--radius);
  font-weight: 600;
}

.skip-link:focus {
  inset-block-start: 0.5rem;
}

/* ---------- Shell ---------- */

.site-header,
.site-footer {
  padding-inline: max(var(--gutter), calc((100% - var(--wide)) / 2));
}

.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand add"
    "nav nav";
  gap: 0.25rem 1rem;
  align-items: center;
  padding-block: 0.75rem 0;
  background: var(--cloth);
  color: var(--cloth-ink);
  border-block-end: 1px solid var(--cloth-deep);
}

.site-header:not(:has(nav)) {
  padding-block-end: 0.75rem;
}

.header-start {
  grid-area: brand;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  min-inline-size: 0;
}

.brand {
  display: inline-flex;
  gap: 0.625rem;
  align-items: center;
  min-block-size: 2.75rem;
  color: var(--cloth-ink);
  font-family: var(--display);
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.brand-mark {
  flex: none;
  inline-size: 1.125rem;
  block-size: 1.5rem;
  fill: none;
  stroke: var(--foil);
  stroke-width: 1.5;
}

.brand-mark rect:last-child {
  fill: var(--foil);
  stroke: none;
}

.site-header nav {
  grid-area: nav;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  align-items: center;
}

.site-header nav a,
.site-header nav .link-button {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  border-block-end: 3px solid transparent;
  color: var(--cloth-ink-soft);
  font-size: 0.9688rem;
  font-weight: 500;
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav .link-button:hover {
  color: var(--cloth-ink);
}

.site-header nav a[aria-current="page"] {
  border-block-end-color: var(--foil);
  color: var(--cloth-ink);
}

.site-header nav .inline-form {
  margin-inline-start: auto;
}

.site-header :focus-visible {
  outline-color: var(--foil);
}

.header-add {
  grid-area: add;
}

.site-header .button-secondary {
  border-color: color-mix(in srgb, var(--cloth-ink) 45%, transparent);
  background: transparent;
  color: var(--cloth-ink);
}

.site-header .button-secondary:hover {
  background: color-mix(in srgb, var(--cloth-ink) 12%, transparent);
}

@media (min-width: 52rem) {
  .site-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "brand nav add";
    gap: 0 2.5rem;
    padding-block: 0;
    min-block-size: 4rem;
  }

  .site-header:not(:has(nav)) {
    padding-block: 0.625rem;
  }

  .site-header nav {
    align-self: stretch;
    gap: 0 1.75rem;
  }

  .site-header nav a,
  .site-header nav .link-button {
    block-size: 100%;
    padding-block-start: 3px;
  }

  .site-header nav .inline-form {
    display: inline-flex;
    align-self: stretch;
  }
}

.page {
  flex: 1 0 auto;
  inline-size: 100%;
  max-inline-size: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding: 1.75rem var(--gutter) 3rem;
}

.page-wide {
  max-inline-size: calc(var(--wide) + 2 * var(--gutter));
}

.site-footer {
  display: flex;
  gap: 1rem;
  padding-block: 1.25rem 2rem;
  border-block-start: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.app-version {
  font-variant-numeric: tabular-nums;
}

/* ---------- Type ---------- */

h1,
h2 {
  font-family: var(--display);
  text-wrap: balance;
}

h1 {
  margin-block: 0 1rem;
  font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.375rem);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.015em;
}

h2 {
  margin-block: 2rem 0.625rem;
  font-size: 1.3125rem;
  font-weight: 600;
  line-height: 1.25;
}

p {
  margin-block: 0.75rem;
}

.muted,
.hint {
  color: var(--ink-soft);
}

.hint {
  margin: 0;
  font-size: 0.9375rem;
}

.back {
  margin-block: 0 1.25rem;
  font-size: 0.9688rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  margin-block-end: 1rem;
}

.page-head h1,
.page-head p {
  margin-block: 0;
}

/* One authored chevron for back links, pagination and disclosures. */
.chevron-prev::before,
.chevron-next::after,
summary::before {
  content: "";
  display: inline-block;
  flex: none;
  inline-size: 1em;
  block-size: 1em;
  background: currentColor;
  -webkit-mask: url("chevron.svg") center / contain no-repeat;
  mask: url("chevron.svg") center / contain no-repeat;
  vertical-align: -0.125em;
}

.chevron-prev::before {
  margin-inline-end: 0.25rem;
  transform: scaleX(-1);
}

.chevron-next::after {
  margin-inline-start: 0.25rem;
}

summary {
  display: flex;
  gap: 0.375rem;
  align-items: center;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  color: var(--ink-soft);
  transition: transform 160ms var(--ease);
}

details[open] > summary::before {
  transform: rotate(90deg);
}

.date,
time,
.book-details dd,
.summary-table td {
  font-variant-numeric: tabular-nums;
}

/* ---------- Status ---------- */

.status-want-to-read { --status: var(--st-want); }
.status-reading { --status: var(--st-reading); }
.status-finished { --status: var(--st-finished); }
.status-abandoned { --status: var(--st-abandoned); }

.status {
  display: inline-flex;
  gap: 0.4375rem;
  align-items: center;
  white-space: nowrap;
}

/* A small spine in the status colour; the label always carries the meaning. */
.status::before {
  content: "";
  flex: none;
  inline-size: 0.4375rem;
  block-size: 0.75rem;
  border-radius: 1px;
  background: var(--status, var(--ink-soft));
}

/* ---------- Controls ---------- */

label {
  font-weight: 600;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
input:not([type]),
select,
textarea {
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  min-block-size: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

select {
  padding-inline-end: 2rem;
}

textarea {
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--ink-soft);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

button,
a.button {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  justify-self: start;
  min-block-size: 2.75rem;
  padding: 0.5rem 1.125rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-ink);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}

button:hover,
a.button:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.button-secondary,
a.button-secondary {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink);
}

.button-secondary:hover,
a.button-secondary:hover {
  border-color: var(--ink-soft);
  background: var(--surface);
}

a.button-foil {
  border-color: var(--foil);
  background: var(--foil);
  color: var(--foil-ink);
}

a.button-foil:hover {
  border-color: var(--foil-hover);
  background: var(--foil-hover);
}

a.button-foil[aria-current="page"] {
  box-shadow: inset 0 -3px 0 var(--foil-ink);
}

.inline-form {
  display: inline;
  margin: 0;
}

.link-button {
  min-block-size: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font-weight: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.link-button:hover {
  border: 0;
  background: none;
  text-decoration-thickness: 2px;
}

.danger-link {
  color: var(--error);
}

.stack {
  display: grid;
  gap: 1rem;
  margin-block: 1.25rem;
}

.field {
  display: grid;
  gap: 0.3125rem;
}

.confirmation {
  display: flex;
  align-items: start;
  gap: 0.75rem;
  min-block-size: 2.75rem;
}

.confirmation input {
  flex: none;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  margin-block-start: 0.25rem;
}

/* ---------- Messages ---------- */

.notice,
.error {
  padding: 0.75rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.notice {
  border-color: color-mix(in srgb, var(--st-reading) 35%, transparent);
  background: var(--notice-ground);
}

.error {
  border-color: color-mix(in srgb, var(--error) 40%, transparent);
  background: var(--error-ground);
  color: var(--error);
}

.error a {
  display: block;
  margin-block-start: 0.25rem;
  color: inherit;
}

.empty-state {
  padding: 1rem 1.125rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink-soft);
}

.empty-state a {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
}

/* ---------- Boards and covers ---------- */

.cloth-1 { --board: var(--cloth-1); }
.cloth-2 { --board: var(--cloth-2); }
.cloth-3 { --board: var(--cloth-3); }
.cloth-4 { --board: var(--cloth-4); }
.cloth-5 { --board: var(--cloth-5); }
.cloth-6 { --board: var(--cloth-6); }
.cloth-7 { --board: var(--cloth-7); }
.cloth-8 { --board: var(--cloth-8); }

/* A cloth board: hinge shadow along the spine, and a blind-stamped panel
   holding the foil title. */
.board,
.volume-cover,
.book-cover {
  display: block;
  inline-size: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 2px 5px 5px 2px;
  box-shadow:
    inset 0.4375rem 0 0 rgb(0 0 0 / 0.22),
    inset 0.5rem 0 0 rgb(255 255 255 / 0.07),
    0 1px 2px rgb(0 0 0 / 0.22),
    0 0.75rem 1.25rem -0.875rem rgb(0 0 0 / 0.45);
}

.board {
  container-type: inline-size;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14% 11% 14% 17%;
  background: var(--board, var(--cloth));
  color: var(--foil);
}

.board-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  align-items: center;
  justify-content: center;
  inline-size: 100%;
  min-block-size: 46%;
  padding: 0.75em 0.5em;
  border: 1px solid rgb(0 0 0 / 0.3);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08), 0 1px 0 rgb(255 255 255 / 0.08);
  text-align: center;
  font-size: clamp(0.75rem, 14cqi, 1.375rem);
}

.board-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.board-author {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-family: var(--display);
  font-size: 0.68em;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.85;
}

.volume-cover,
.book-cover {
  block-size: auto;
  object-fit: cover;
  background: var(--surface-sunk);
}

/* ---------- Library ---------- */

.library {
  display: grid;
  gap: 1.5rem;
}

.library-foot .side-links {
  margin-block-start: 0;
}

.list-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem 0.5rem;
  align-items: end;
  margin: 0;
}

.filter-panel {
  grid-column: 1 / -1;
  border-block: 1px solid var(--line);
}

.filter-panel > summary {
  min-block-size: 2.75rem;
  padding-block: 0.625rem;
  cursor: pointer;
  font-weight: 600;
}

.filter-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  padding-block-end: 0.75rem;
}

.filter-fields p {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  min-inline-size: 0;
}

.filter-fields details {
  grid-column: 1 / -1;
}

.list-controls p {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  min-inline-size: 0;
}

.list-controls label,
.more-filters legend,
.tag-filter legend {
  font-size: 0.9375rem;
}

.list-controls .control-submit button {
  inline-size: auto;
}

.tag-filter,
.more-filters {
  min-inline-size: 0;
  border-block-start: 1px solid var(--line);
}

.tag-filter summary,
.more-filters summary {
  display: flex;
  min-block-size: 2.75rem;
  padding-block: 0.625rem;
  cursor: pointer;
  font-weight: 600;
}

.tag-filter fieldset,
.more-filters fieldset {
  margin: 0;
  padding: 0.5rem 0.75rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tag-filter legend,
.more-filters legend {
  padding-inline: 0.25rem;
  color: var(--ink-soft);
}

.more-filters p,
.more-filters fieldset {
  margin-block: 0.5rem 0.75rem;
}

.more-filters fieldset p {
  margin-block: 0.5rem 0;
}

.tag-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  margin: 0;
  padding: 0;
  max-block-size: 16rem;
  overflow-y: auto;
  list-style: none;
}

.tag-choices li {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  min-block-size: 2.75rem;
  max-inline-size: 100%;
}

.tag-choices input {
  flex: none;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  margin: 0;
}

.tag-choices label {
  font-weight: 400;
}


.side-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9375rem;
}

.side-links a {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
}

.signed-in {
  margin-block: 0.25rem 0;
  font-size: 0.875rem;
}

.result-count {
  margin-block: 0 1rem;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.shelf {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.volume {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-inline-size: 0;
  font-size: 0.9375rem;
}

.volume-link {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  color: var(--ink);
  text-decoration: none;
}

.volume-frame {
  position: relative;
  display: block;
}

.volume-link .board,
.volume-link .volume-cover {
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease);
}

/* Taking a book off the shelf: the board lifts and its shadow deepens. */
.volume-link:hover .board,
.volume-link:hover .volume-cover,
.volume-link:focus-visible .board,
.volume-link:focus-visible .volume-cover {
  transform: translateY(-0.25rem);
  box-shadow:
    inset 0.4375rem 0 0 rgb(0 0 0 / 0.22),
    inset 0.5rem 0 0 rgb(255 255 255 / 0.07),
    0 2px 3px rgb(0 0 0 / 0.2),
    0 1.25rem 1.5rem -0.875rem rgb(0 0 0 / 0.55);
}

.volume-link:focus-visible {
  outline: none;
}

.volume-link:focus-visible .board,
.volume-link:focus-visible .volume-cover {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.volume-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.3;
}

.volume-link:hover .volume-title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.book-authors {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--ink-soft);
}

.volume-meta {
  color: var(--ink-soft);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.volume-date {
  color: var(--ink-soft);
  font-size: 0.8125rem;
}

.volume-meta .status {
  color: var(--ink);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin-block-start: 2.5rem;
  padding-block-start: 1.25rem;
  border-block-start: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.empty-shelf {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  gap: 1.5rem;
  align-items: center;
  max-inline-size: 38rem;
}

.empty-shelf .empty-state {
  margin-block-start: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 1.125rem;
}

.board-empty {
  border: 2px dashed var(--line-strong);
  background: transparent;
  box-shadow: none;
}

.board-empty .board-panel {
  border-color: var(--line);
  box-shadow: none;
}

@media (min-width: 30rem) {
  .shelf {
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  }
}

@media (min-width: 64rem) {
  .library {
    grid-template-columns: 18rem minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    gap: 1.5rem 3rem;
    align-items: start;
  }

  .library-side {
    grid-column: 1;
    grid-row: 1;
  }

  .library-results {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .library-foot {
    grid-column: 1;
    grid-row: 2;
  }

  .list-controls,
  .filter-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .list-controls .control-submit {
    grid-row: 3;
  }

  .list-controls .control-submit button {
    inline-size: 100%;
  }

  .shelf {
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 2.25rem 1.5rem;
  }

  .library-results .result-count {
    margin-block-start: 0.375rem;
  }
}

/* Desktop has room for every filter, so the disclosure stays open in
   browsers that can style its content; elsewhere it remains a working
   disclosure. */
@supports selector(::details-content) {
  @media (min-width: 64rem) {
    .filter-panel > summary {
      display: none;
    }

    .filter-panel::details-content {
      content-visibility: visible;
      block-size: auto;
    }

    .filter-panel {
      border-block-end: 0;
      padding-block-start: 0.75rem;
    }
  }
}

/* ---------- Book ---------- */

.book-head {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 1.25rem;
  align-items: end;
}

.book-volume {
  position: relative;
}

.book-volume .book-cover {
  inline-size: 100%;
}

.foil-stamp {
  position: absolute;
  inset-inline-end: 0.5rem;
  inset-block-end: 0.625rem;
  padding: 0.25rem 0.5rem;
  border: 1.5px solid var(--foil);
  border-radius: 2px;
  background: var(--cloth-deep);
  color: var(--foil);
  font-family: var(--display);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.3);
}

.foil-stamp-small {
  inset-inline-end: 0.375rem;
  inset-block-end: 0.375rem;
  padding: 0.125rem 0.3125rem;
  border-width: 1px;
  font-size: 0.5625rem;
  letter-spacing: 0.12em;
  pointer-events: none;
}

.volume-span {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-block-start: 0.25rem;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.span-scale-small {
  flex: 1 1 auto;
  block-size: 0.375rem;
  margin: 0;
}

.span-days {
  flex: none;
}

.book-title h1 {
  margin-block-end: 0.375rem;
}

.book-byline {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.0625rem;
}

/* Facts as labelled segments with tabular figures. */
.book-details {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.5rem), 1fr));
  gap: 0.25rem 0;
  margin-block: 1.75rem 0;
  padding-block: 0.5rem;
  border-block: 1px solid var(--line);
}

.book-details > div {
  padding: 0.375rem 0.75rem 0.375rem 0;
}

.book-details dt {
  color: var(--ink-soft);
  font-family: var(--display);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.book-details dd {
  margin: 0.125rem 0 0;
  font-size: 1.0625rem;
  font-weight: 600;
}

.fact-status dd::before {
  content: "";
  display: inline-block;
  inline-size: 0.4375rem;
  block-size: 0.75rem;
  margin-inline-end: 0.4375rem;
  border-radius: 1px;
  background: var(--status);
}

.reading-span {
  margin: 1.5rem 0 0;
}

.reading-span figcaption {
  font-family: var(--display);
  font-size: 1.0625rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.span-scale {
  display: block;
  inline-size: 100%;
  block-size: 0.875rem;
  margin-block: 0.5rem 0.25rem;
}

.span-dates {
  display: block;
  color: var(--ink-soft);
  font-family: var(--text);
  font-size: 0.875rem;
  font-weight: 400;
}

.span-track {
  fill: color-mix(in srgb, var(--line-strong) 30%, transparent);
}

.span-bar {
  fill: var(--st-finished);
}

.span-ticks {
  stroke: var(--ground);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.span-axis {
  display: flex;
  justify-content: space-between;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block: 0.75rem;
  padding: 0;
  list-style: none;
}

.tag-list li {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
  align-items: center;
  max-inline-size: 100%;
  min-block-size: 2.75rem;
  padding: 0.125rem 0.375rem 0.125rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.tag-list a {
  font-weight: 600;
  text-decoration: none;
}

.tag-list .link-button {
  min-block-size: 2.5rem;
  padding-inline: 0.5rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

.tag-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: start;
}

.tag-form p {
  display: grid;
  flex: 1 1 14rem;
  gap: 0.25rem;
  margin: 0;
  min-inline-size: 0;
}

.tag-form p:last-child {
  flex: 0 0 auto;
  padding-block-start: 1.85rem;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: center;
  margin-block: 2rem;
  padding-block-start: 1.5rem;
  border-block-start: 1px solid var(--line);
}

.book-actions a:not(.button) {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
}

.note-form {
  display: grid;
  gap: 0.75rem;
}

.note-form p {
  margin: 0;
  min-inline-size: 0;
}

.note-form label,
.note-form .hint {
  display: block;
}

.note-form label {
  margin-block-end: 0.25rem;
}

.note-form .hint {
  margin-block-start: 0.25rem;
}

.note-list {
  display: grid;
  gap: 1rem;
  margin-block: 1.75rem 0;
  padding: 0;
  list-style: none;
}

.note-list li {
  padding: 1rem 1.125rem 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.note-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 1.0625rem;
  line-height: 1.65;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
  align-items: center;
  margin: 0.5rem 0 0;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

.note-meta a {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  margin-inline-start: auto;
}

.note-delete {
  margin-block-start: 2rem;
  padding-block-start: 1rem;
  border-block-start: 1px solid var(--line);
}

.note-delete a {
  color: var(--error);
}

@media (min-width: 40rem) {
  .book-head {
    grid-template-columns: 10rem minmax(0, 1fr);
    gap: 1.75rem;
  }
}

@media (min-width: 64rem) {
  .book-page {
    display: grid;
    grid-template-columns: minmax(0, 30rem) minmax(0, 1fr);
    gap: 0 4rem;
    align-items: start;
  }

  .book-page > .notice {
    grid-column: 1 / -1;
  }

  .book-head {
    grid-template-columns: 11rem minmax(0, 1fr);
  }

  .notes h2 {
    margin-block-start: 0;
  }
}

/* ---------- Add and edit ---------- */

.book-form {
  display: grid;
  gap: 1rem;
}

.book-form p {
  margin: 0;
  min-inline-size: 0;
}

.book-form label,
.book-form .hint {
  display: block;
}

.book-form label {
  margin-block-end: 0.25rem;
}

.book-form .check-field {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  align-items: center;
}

.book-form .check-field input {
  flex: none;
  inline-size: 1.25rem;
  min-block-size: 0;
  block-size: 1.25rem;
  margin: 0;
  padding: 0;
}

.book-form .check-field label {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  margin: 0;
}

.book-form .check-field .hint {
  flex-basis: 100%;
}

.lookup {
  margin-block-end: 2rem;
  padding: 1.25rem;
  border-radius: var(--radius-card);
  background: var(--cloth);
  color: var(--cloth-ink);
}

.lookup h2 {
  margin-block: 0 0.75rem;
  color: var(--cloth-ink);
  font-size: 1.1875rem;
}

.lookup a,
.lookup summary {
  color: var(--cloth-ink);
}

.lookup .hint,
.lookup details p {
  color: var(--cloth-ink-soft);
}

.lookup :focus-visible {
  outline-color: var(--foil);
}

.lookup input {
  border-color: transparent;
}

.lookup button {
  border-color: var(--cloth-ink);
  background: var(--cloth-ink);
  color: var(--cloth);
}

.lookup button:hover {
  border-color: var(--cloth-ink-hover);
  background: var(--cloth-ink-hover);
}

.lookup .error {
  background: var(--error-ground);
}

.lookup code {
  overflow-wrap: anywhere;
}

.lookup details {
  margin-block-start: 0.75rem;
  font-size: 0.9375rem;
}

.lookup summary {
  display: flex;
  min-block-size: 2.75rem;
  padding-block: 0.625rem;
  cursor: pointer;
  font-weight: 600;
}

.lookup-form label,
.lookup-form .hint {
  display: block;
}

.lookup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block: 0.375rem;
}

.lookup-row input {
  flex: 1 1 12rem;
}

.lookup-results {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.lookup-results li {
  padding-block: 0.75rem;
  border-block-start: 1px solid rgb(255 255 255 / 0.14);
}

.lookup-results form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
}

.lookup-book {
  flex: 1 1 14rem;
  min-inline-size: 0;
}

.lookup-book .hint {
  font-size: inherit;
}

.edit-layout {
  max-inline-size: 46rem;
}

@media (min-width: 40rem) {
  .book-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1.25rem;
  }

  .book-form > * {
    grid-column: 1 / -1;
  }

  .book-form > .pair {
    grid-column: auto;
  }
}

@media (min-width: 64rem) {
  .add-layout {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 3.5rem;
    align-items: start;
  }

  .add-layout .lookup {
    position: sticky;
    inset-block-start: 1.25rem;
    margin-block-end: 0;
  }

  .add-layout .book-details-form > h2 {
    margin-block-start: 0;
  }
}

/* ---------- Summary ---------- */

.lede {
  margin-block: 0 1.5rem;
  color: var(--ink-soft);
  font-size: 1.125rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 0 3rem;
  align-items: start;
}

.summary-table {
  inline-size: 100%;
  margin-block: 1.25rem;
  border-collapse: collapse;
}

.summary-table caption {
  padding-block-end: 0.75rem;
  font-family: var(--display);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: start;
  text-transform: uppercase;
}

/* A finish year drawn as a shelf: one cloth spine per book. */
.spines {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 3px;
  align-items: end;
  padding-block: 0.625rem 0;
  border-block-end: 3px solid var(--line-strong);
}

.count > .spines {
  justify-content: flex-start;
  min-block-size: 4rem;
}

.spine {
  inline-size: 0.875rem;
  block-size: 3rem;
  border-radius: 2px 2px 0 0;
  background: var(--board);
  box-shadow:
    inset 2px 0 0 rgb(255 255 255 / 0.12),
    inset 0 0.5rem 0 rgb(0 0 0 / 0.12),
    inset 0 -0.625rem 0 rgb(0 0 0 / 0.12);
}

.spine:nth-child(3n) {
  block-size: 2.625rem;
}

.spine:nth-child(4n + 1) {
  block-size: 3.375rem;
  inline-size: 1rem;
}

/* Year label and count stand on the shelf rule with the spines. */
.summary-table tr:has(.spines) th {
  vertical-align: bottom;
  padding-block-end: 0.5rem;
}

.summary-table td .spines + a {
  align-self: end;
  min-block-size: 0;
  padding-block-end: 0.25rem;
}

.summary-table th,
.summary-table td {
  padding: 0.25rem 0;
  border-block-end: 1px solid var(--line);
  text-align: start;
}

.summary-table thead th {
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-weight: 500;
}

.summary-table thead th:last-child {
  text-align: end;
}

.summary-table tbody th {
  padding-inline-end: 1rem;
  font-weight: 400;
  white-space: nowrap;
}

.summary-table td {
  inline-size: 60%;
}

.count {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.75rem;
  gap: 0.5rem;
  align-items: center;
}

.count > a,
.count > span {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-block-size: 2.75rem;
  font-weight: 600;
}

.count > span {
  color: var(--ink-soft);
  font-weight: 400;
}

/* Status and rating counts as strips of bookcloth with a hinge. */
.count-bar {
  display: block;
  inline-size: 100%;
  block-size: 0.875rem;
}

.count-track {
  fill: var(--surface-sunk);
}

.count-fill {
  fill: var(--status, var(--primary));
}

.count-muted {
  fill: var(--st-abandoned);
}

/* ---------- Account and admin ---------- */

.settings-section {
  margin-block-start: 1.75rem;
  padding-block-start: 0.25rem;
  border-block-start: 1px solid var(--line);
}

.settings-section .stack {
  max-inline-size: 32rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 0 3rem;
  align-items: start;
}

@media (min-width: 64rem) {
  .settings-grid .settings-section {
    padding: 0.25rem 1.5rem 1.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface);
  }
}

.account-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 1rem;
  margin-block: 1.25rem 0;
  padding: 0;
  list-style: none;
}

.account-list li {
  padding: 0.875rem 1.125rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.account-list a,
.account-list .link-button {
  display: inline-block;
  padding-block: 0.5rem;
}

.account-list p {
  margin-block: 0.25rem 0;
}

.account-email {
  overflow-wrap: anywhere;
}

/* Keep all five management columns visible on target phones; long
   identities and timestamps wrap within their cells. */
.account-table {
  inline-size: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-block: 1.25rem;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.account-table caption {
  margin-block-end: 0.5rem;
  color: var(--ink-soft);
  text-align: start;
}

.account-table col { inline-size: 18%; }
.account-table .identity-column { inline-size: 32%; }
.account-table .signin-column { inline-size: 18%; }
.account-table col:last-child { inline-size: 14%; }

.account-table th,
.account-table td {
  padding: 0.5rem 0.25rem;
  border-block-end: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.account-table thead th {
  border-block-end-color: var(--line-strong);
  color: var(--ink-soft);
  font-weight: 600;
}

.account-table tbody th { font-weight: normal; }
.account-table tbody tr:hover { background: var(--surface); }
.account-table th a { display: block; padding-block: 0.5rem; }
.account-table .hint { display: block; font-size: inherit; }

@media (min-width: 40rem) {
  .account-table { font-size: 1rem; }

  .account-table th,
  .account-table td { padding: 0.75rem; }
}

.account-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.25rem;
}

.account-facts dt {
  color: var(--ink-soft);
}

.account-facts dd {
  margin: 0;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
  }

  .volume-link:hover .board,
  .volume-link:hover .volume-cover,
  .volume-link:focus-visible .board,
  .volume-link:focus-visible .volume-cover {
    transform: none;
  }
}

/* Author shelf and catalogue: the reader's volumes first, then a compact index. */
.author-page > h1 { margin-bottom: 2rem; overflow-wrap: anywhere; }
.author-shelf { margin-bottom: 3rem; }
.author-shelf .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.author-count { font-size: 1rem; font-variant-numeric: tabular-nums; }
.author-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.author-section-head h2 { margin: 0; }
.author-section-head .hint { margin: 0.5rem 0 1rem; }
.author-section-head form { margin: 0; }
.author-works { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line-strong); }
.author-work { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); scroll-margin-top: 1rem; }
.author-work > div { min-width: 0; }
.author-work h3 { font: 650 1rem/1.4 var(--text); margin: 0; overflow-wrap: anywhere; }
.author-work form { flex: none; margin: 0; }
.author-work button { min-width: 4.5rem; }
.author-year { margin: 0.25rem 0 0; font-variant-numeric: tabular-nums; }
.on-shelf { display: inline-flex; align-items: center; min-height: 2.75rem; flex: none; font-size: 0.9375rem; font-weight: 600; }
.author-work:target { background: var(--notice-ground); outline: 2px solid var(--line-strong); outline-offset: 3px; }
@media (min-width: 30rem) { .author-shelf .shelf { grid-template-columns: repeat(auto-fill, 9.5rem); } }
@media (min-width: 64rem) { .author-catalogue { max-width: 64rem; } }
