/* ---- Design tokens --------------------------------------------------------
   Every colour, shadow and radius lives here (a test enforces it). Light by
   default; dark when the device prefers it and the user didn't choose light,
   or when the user chose dark (data-theme on <html>, rendered by the server,
   so there is no flash). */
:root {
  color-scheme: light dark;
  --font-heading: "Literata", Georgia, serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, sans-serif;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --radius-round: 50%;
  --bg: #FBF8F3;
  --surface: #FFFFFF;
  --surface-2: #F1EADF;
  --border: #ECE4D8;
  --text: #1F1A16;
  --muted: #6E6358;
  --accent: #8B5E34;
  --on-accent: #FFFFFF;
  --success: #2F6B45;
  --danger: #B3261E;
  --header-bg: rgba(251, 248, 243, 0.82);
  --cover-shadow: 0 0 0 1px rgba(31, 26, 22, 0.06), 0 1px 2px rgba(31, 26, 22, 0.08), 0 10px 24px rgba(31, 26, 22, 0.12);
  --cover-shadow-hover: 0 0 0 1px rgba(31, 26, 22, 0.06), 0 2px 4px rgba(31, 26, 22, 0.1), 0 16px 32px rgba(31, 26, 22, 0.18);
  /* On a book's own colour (hero, placeholder): same in both themes. */
  --ink-light: #FFFFFF;
  --ink-dark: #1F1A16;
  --glass-light: rgba(255, 255, 255, 0.16);
  --glass-dark: rgba(31, 26, 22, 0.1);
  --hero-cover-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
  --accent-hover: #74502C;
  --on-danger: #FFFFFF;
  --danger-hover: #8F1E17;
  --danger-bg: #FDF3F1;
  --danger-border: #E3B3A9;
  --success-bg: #EAF3EA;
  --warning: #7A5F2E;
  --warning-bg: #FBF3E3;
  --warning-border: #EFE0BD;
  --info: #2C5A80;
  --info-bg: #DBE8F2;
  --neutral-bg: #EEE6D8;
  --marker-bg: rgba(251, 248, 243, 0.92);
  --banner-bg: rgba(139, 94, 52, 0.5);
  --banner-text: rgba(255, 255, 255, 0.95);
  --placeholder-border: #D8CDB9;
  --shadow-menu: 0 6px 20px rgba(31, 26, 22, 0.14);
  --backdrop: rgba(31, 26, 22, 0.4);
  --shadow-marker: 0 1px 3px rgba(31, 26, 22, 0.25);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236E6358' stroke-width='1.6'/%3E%3C/svg%3E");
}

:root[data-theme="light"] {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15120F;
    --surface: #1E1A16;
    --surface-2: #2A231D;
    --border: #332B24;
    --text: #EEE7DD;
    --muted: #A3968A;
    --accent: #D6A26D;
    --on-accent: #1A140F;
    --success: #7BC193;
    --danger: #F2867D;
    --header-bg: rgba(21, 18, 15, 0.78);
    --cover-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 10px 24px rgba(0, 0, 0, 0.45);
    --cover-shadow-hover: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 16px 32px rgba(0, 0, 0, 0.6);
    --ink-light: #FFFFFF;
    --ink-dark: #1F1A16;
    --glass-light: rgba(255, 255, 255, 0.16);
    --glass-dark: rgba(31, 26, 22, 0.1);
    --hero-cover-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
    --accent-hover: #E3B583;
    --on-danger: #1A140F;
    --danger-hover: #F5A099;
    --danger-bg: #3A1F1C;
    --danger-border: #6B3530;
    --success-bg: #1D3326;
    --warning: #E2C07A;
    --warning-bg: #352B1B;
    --warning-border: #5A4A2C;
    --info: #8DB8E0;
    --info-bg: #1C2A36;
    --neutral-bg: #2A231D;
    --marker-bg: rgba(30, 26, 22, 0.9);
    --banner-bg: rgba(214, 162, 109, 0.45);
    --banner-text: rgba(255, 255, 255, 0.9);
    --placeholder-border: #4A3F35;
    --shadow-menu: 0 6px 20px rgba(0, 0, 0, 0.5);
    --backdrop: rgba(0, 0, 0, 0.6);
    --shadow-marker: 0 1px 3px rgba(0, 0, 0, 0.5);
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23A3968A' stroke-width='1.6'/%3E%3C/svg%3E");
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15120F;
  --surface: #1E1A16;
  --surface-2: #2A231D;
  --border: #332B24;
  --text: #EEE7DD;
  --muted: #A3968A;
  --accent: #D6A26D;
  --on-accent: #1A140F;
  --success: #7BC193;
  --danger: #F2867D;
  --header-bg: rgba(21, 18, 15, 0.78);
  --cover-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 10px 24px rgba(0, 0, 0, 0.45);
  --cover-shadow-hover: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 16px 32px rgba(0, 0, 0, 0.6);
  --ink-light: #FFFFFF;
  --ink-dark: #1F1A16;
  --glass-light: rgba(255, 255, 255, 0.16);
  --glass-dark: rgba(31, 26, 22, 0.1);
  --hero-cover-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
  --accent-hover: #E3B583;
  --on-danger: #1A140F;
  --danger-hover: #F5A099;
  --danger-bg: #3A1F1C;
  --danger-border: #6B3530;
  --success-bg: #1D3326;
  --warning: #E2C07A;
  --warning-bg: #352B1B;
  --warning-border: #5A4A2C;
  --info: #8DB8E0;
  --info-bg: #1C2A36;
  --neutral-bg: #2A231D;
  --marker-bg: rgba(30, 26, 22, 0.9);
  --banner-bg: rgba(214, 162, 109, 0.45);
  --banner-text: rgba(255, 255, 255, 0.9);
  --placeholder-border: #4A3F35;
  --shadow-menu: 0 6px 20px rgba(0, 0, 0, 0.5);
  --backdrop: rgba(0, 0, 0, 0.6);
  --shadow-marker: 0 1px 3px rgba(0, 0, 0, 0.5);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23A3968A' stroke-width='1.6'/%3E%3C/svg%3E");
}
/* ---- End of design tokens ---- */

/* ---- Motion ---------------------------------------------------------------
   Cross-page view transitions (Safari, Chrome): a cover named
   cover-<id> on a card and on the book page glides between them; other
   browsers just navigate. Everything is switched off for people who ask for
   less motion. */
@view-transition {
  navigation: auto;
}

::view-transition-group(*) {
  animation-duration: 0.3s;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .book-card:hover .book-cover,
  .book-card:focus-visible .book-cover,
  .button-primary:active,
  .button-secondary:active,
  .button-danger:active {
    transform: none !important;
  }
}

/* ---- Fonts (self-hosted, SIL OFL; see static/fonts/README.md) ---- */
@font-face {
  font-family: "Literata";
  src: url("../fonts/literata-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  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: "Literata";
  src: url("../fonts/literata-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  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;
}
@font-face {
  font-family: "Literata";
  src: url("../fonts/literata-latin-wght-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  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: "Instrument Sans";
  src: url("../fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 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: "Instrument Sans";
  src: url("../fonts/instrument-sans-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 400 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;
}


* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: 500;
}

/* One focus ring for everything you can tab to. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Form controls: no grey OS widgets. */
input[type="text"],
input[type="password"],
input[type="url"],
input[type="email"],
input[type="number"],
select,
textarea {
  min-height: 44px;
  width: 100%;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 8rem;
  padding: 0.6rem 0.75rem;
  line-height: 1.5;
  resize: vertical;
}

select {
  appearance: none;
  padding-right: 2.25rem;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

input[type="file"] {
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="file"]::file-selector-button {
  min-height: 36px;
  margin-right: 0.75rem;
  padding: 0 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1.1rem;
  height: 1.1rem;
}

.develop-banner {
  position: fixed;
  top: 26px;
  left: -52px;
  width: 200px;
  transform: rotate(-45deg);
  background: var(--banner-bg);
  color: var(--banner-text);
  text-align: center;
  padding: 6px 0;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  z-index: 9999;
  pointer-events: none;
}

.site-header {
  font-family: var(--font-body);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

/* Same width and side padding as `main`, so brand, search and nav line up
   with the page content; the border underneath stays full-width. */
.site-header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 2rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.brand-group {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

/* 11px muted, also over the generic .secondary size. */
.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  flex: none;
}

.brand-group .brand-version {
  font-size: 0.6875rem;
}

.brand-version {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  color: var(--muted);
}

.header-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* "/" hint at the end of the search field: mouse/keyboard devices only,
   gone once you type or focus it. */
.search-hint {
  display: none;
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  min-width: 1.4rem;
  padding: 0 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.75rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .header-search input:placeholder-shown:not(:focus) ~ .search-hint {
    display: block;
  }
}

.header-search input {
  width: 100%;
  min-height: 42px;
  padding: 0 2.75rem 0 0.9rem;
  font: inherit;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  /* The last item's own padding would otherwise leave its text short of
     the content's right edge. */
  margin-right: -0.75rem;
}

.site-nav > a,
.nav-menu > summary {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 40px;
  padding: 0 0.75rem;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* Dropdown menus are plain <details>: no JS. */
.site-nav > a:hover,
.nav-menu > summary:hover,
.site-nav > a.nav-active,
.nav-menu > summary.nav-active,
.nav-menu[open] > summary {
  background: var(--surface-2);
  color: var(--text);
}

.nav-menu {
  position: relative;
}

.nav-menu > summary {
  list-style: none;
}

.nav-menu > summary::-webkit-details-marker {
  display: none;
}

.nav-menu > summary::after {
  content: "▾";
  font-size: 0.75em;
}

.nav-menu-panel {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 10;
  min-width: 180px;
  padding: 0.35rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-menu);
  font-family: var(--font-body);
}

.nav-menu-panel a,
.nav-menu-panel button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-height: 44px;
  padding: 0 1rem;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav-menu-panel a:hover,
.nav-menu-panel button:hover {
  background: var(--bg);
}

/* System / Light / Dark, in the account menu. */
/* Theme and language: segmented controls in the user menu. */
.theme-switch,
.language-switch {
  display: flex;
  gap: 0.25rem;
  margin: 0.35rem 0.75rem 0.5rem;
  padding: 0.25rem;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.language-switch {
  margin-top: 0;
}

.nav-menu-panel .theme-switch button,
.nav-menu-panel .language-switch button {
  flex: 1;
  justify-content: center;
  min-height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  color: var(--muted);
}

.nav-menu-panel .language-switch button {
  font-size: 0.85rem;
}

.nav-menu-panel .theme-switch button[aria-pressed="true"],
.nav-menu-panel .language-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-marker);
}

.badge {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 0.4em;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.site-footer {
  max-width: 1200px;
  margin: 2rem auto 0;
  padding: 1.5rem 2rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--muted);
}

main {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Below 900px (iPad portrait and smaller) the search gets its own
   full-width row under brand and nav, rather than being squeezed between
   them. */
@media (max-width: 899px) {
  .site-header-inner {
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }
  .header-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
    margin-bottom: 0.5rem;
  }
}

/* Phones: the nav also gets its own row, under the brand. */
@media (max-width: 700px) {
  .site-header-inner {
    padding: 0.5rem 1rem;
    gap: 0.25rem 1rem;
  }
  /* Item text flush with the content edge. */
  .site-nav {
    flex-wrap: wrap;
    gap: 0;
    order: 2;
    flex-basis: calc(100% + 1rem);
    margin-left: -0.5rem;
    margin-right: -0.5rem;
  }
  .site-nav > a,
  .nav-menu > summary {
    padding: 0 0.5rem;
  }
  main {
    padding: 1.25rem 1rem;
  }
  .site-footer {
    padding: 1.25rem 1rem 1.5rem;
  }
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2rem 1.5rem;
}

/* Quiet, cover-first card: the whole card is one link to the book page. */
.book-card {
  display: block;
  color: inherit;
  text-decoration: none;
}

.book-card:focus-visible .book-cover {
  transform: translateY(-2px);
  box-shadow: var(--cover-shadow-hover);
}

@media (hover: hover) and (pointer: fine) {
  .book-card:hover .book-cover {
    transform: translateY(-2px);
    box-shadow: var(--cover-shadow-hover);
  }
}

/* Covers and the typographic placeholder share one fixed 2:3 box, so
   title/author start at the same height on every card. */
.book-cover {
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: var(--cover-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24% 10% 12%;
  text-align: center;
  font-family: var(--font-heading);
  color: var(--ink-light);
  border: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--book-color, var(--surface-2));
}

.book-cover-placeholder-title {
  font-size: 1.05rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-cover-placeholder-author {
  font-size: 0.8rem;
  font-style: italic;
  color: inherit;
  opacity: 0.8;
}

.book-card-title {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.3;
  margin: 0.65rem 0 0.15rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
}

.book-card-author {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card-cover {
  position: relative;
}

/* Corner markers: on my want-to-read list / downloaded by me. */
.book-markers {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
}

.book-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-round);
  background: var(--marker-bg);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: var(--shadow-marker);
}

.book-card-note {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.secondary {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Discover */

.featured {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 2.5rem;
  align-items: center;
  padding: 2.25rem 2.5rem;
  margin-bottom: 2.5rem;
  background: var(--book-color, var(--surface-2));
  border: none;
  border-radius: var(--radius-lg);
  color: var(--ink-light);
}

/* Text on the book's colour: light or dark ink, whichever reads (cover_color.ink). */
.ink-dark,
.featured.ink-dark {
  color: var(--ink-dark);
}

.featured.ink-dark .featured-label {
  background: var(--glass-dark);
}

.featured .button-primary {
  background: var(--ink-light);
  border-color: var(--ink-light);
  color: var(--ink-dark);
}

.featured.ink-dark .button-primary {
  background: var(--ink-dark);
  border-color: var(--ink-dark);
  color: var(--ink-light);
}

.featured .button-secondary,
.featured .button-secondary-active {
  background: var(--glass-light);
  color: inherit;
}

.featured .button-secondary:hover {
  background: color-mix(in srgb, var(--glass-light), var(--ink-light) 12%);
}

.featured.ink-dark .button-secondary,
.featured.ink-dark .button-secondary-active {
  background: var(--glass-dark);
}

.featured .book-cover {
  box-shadow: var(--hero-cover-shadow);
}

/* The cover link: no link underline/colour on the typographic placeholder. */
.featured-cover {
  color: inherit;
  text-decoration: none;
}

.featured-label {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: inherit;
  display: inline-block;
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--glass-light);
}

.featured-title {
  font-family: var(--font-heading);
  font-size: clamp(2.25rem, 4vw, 3.25rem);
  line-height: 1.1;
  margin: 0 0 0.25rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.featured-title a {
  color: inherit;
  text-decoration: none;
}

.featured-author {
  margin: 0 0 0.85rem;
  color: inherit;
  opacity: 0.85;
}

.featured-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.featured-actions .inline-form {
  margin: 0;
}

.featured-description {
  margin: 0 0 1.25rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: inherit;
  opacity: 0.9;
}

.shelf {
  margin-bottom: 2.5rem;
}

.shelf-head {
  display: flex;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.85rem;
}

.shelf-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 500;
  margin: 0 auto 0 0;
  letter-spacing: -0.01em;
}

.shelf-subtitle {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.shelf-see-all {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
}

/* Previous/next: only for a mouse, and only once shelves.js has decided
   the row overflows (it removes `hidden`). Touch devices swipe instead. */
.shelf-nav {
  display: none;
  gap: 0.35rem;
}

@media (hover: hover) and (pointer: fine) {
  .shelf-nav:not([hidden]) {
    display: inline-flex;
  }
}

.shelf-nav-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-round);
  background: var(--surface);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.shelf-nav-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.shelf-nav-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.shelf-scroller {
  position: relative;
}

/* Soft fade on the right edge while there is more to scroll (class set by
   shelves.js). */
.shelf-scroller::after {
  content: "";
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  width: 64px;
  background: linear-gradient(to right, transparent, var(--bg));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.shelf-more-right .shelf-scroller::after {
  opacity: 1;
}

/* One row that scrolls sideways; snaps per book on touch. Padding leaves
   room for the cover shadow and the hover lift. The native scrollbar is
   hidden: touch swipes, a mouse gets the buttons (or shift + wheel). */
.shelf-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 150px;
  gap: 1.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 4px 4px 12px;
  margin: 0 -4px;
  scrollbar-width: none;
}

.shelf-row::-webkit-scrollbar {
  display: none;
}

.shelf-row .book-card {
  scroll-snap-align: start;
}

/* Phones: the row runs to the screen edges (minus the page padding), so it
   reads as something to swipe; snapping still lines books up with the text. */
@media (max-width: 700px) {
  .shelf-row {
    margin: 0 -1rem;
    padding: 4px 1rem 12px;
    scroll-padding-inline: 1rem;
  }
  .shelf-scroller::after {
    right: -1rem;
  }
}

@media (max-width: 700px) {
  .featured {
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 1.25rem;
    padding: 1.25rem;
  }
  .featured-title {
    font-size: 1.35rem;
  }
  .shelf-row {
    grid-auto-columns: 120px;
    gap: 1rem;
  }
}

.book-page + .shelf {
  margin-top: 3.5rem;
}

/* Book page */

.book-band-wrap {
  position: relative;
  isolation: isolate;
  padding: 1.5rem 1.75rem 0;
}

.book-band {
  position: absolute;
  inset: 0 0 auto 0;
  height: 320px;
  z-index: -1;
  border-radius: var(--radius-lg);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--book-color) 32%, var(--bg)), var(--bg));
}


.back-link {
  margin: 0 0 1.5rem;
}

.book-page {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}

.book-page-title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 3.5vw, 2.75rem);
  line-height: 1.15;
  margin: 0 0 0.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.book-page-author {
  font-size: 1.1rem;
  margin: 0 0 1.5rem;
}

.book-page-author:has(+ .book-page-series) {
  margin-bottom: 0.35rem;
}

.book-page-series {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.book-page-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

/* Buttons: one set for the whole app, on <a> and <button> alike. */
.button-primary,
.button-secondary,
.button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

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

.button-secondary {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text);
}

.button-secondary:hover {
  background: color-mix(in srgb, var(--surface-2), var(--text) 8%);
}

.button-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}

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

/* A small press. */
.button-primary,
.button-secondary,
.button-danger {
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.button-primary:active,
.button-secondary:active,
.button-danger:active {
  transform: scale(0.98);
}

/* Table rows and other tight spots. */
.button-small {
  min-height: 36px;
  padding: 0 0.85rem;
  font-size: 0.85rem;
}

.button-primary:disabled,
.button-secondary:disabled,
.button-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button-secondary-active {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  border-color: transparent;
  color: var(--accent);
}

.book-page-actions .inline-form {
  margin: 0;
}

.book-page-downloaded {
  margin: -1rem 0 1.75rem;
}

/* Liked it / Not for me */

.rating-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.rating-panel p {
  margin: 0;
  margin-right: auto;
  font-size: 0.9rem;
  color: var(--muted);
}

.rating-buttons {
  display: flex;
  gap: 0.4rem;
}

.rating-buttons form {
  margin: 0;
}

.rating-button {
  min-height: 44px;
  padding: 0 0.9rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.rating-button:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--surface-2), var(--text) 8%);
}

.rating-button-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.book-card-with-actions .rating-buttons {
  margin-top: 0.5rem;
}

.book-card-with-actions .rating-button {
  flex: 1;
  padding: 0 0.4rem;
  font-size: 0.75rem;
}

.book-card-with-actions .rating-buttons form {
  flex: 1;
  display: flex;
}

/* My books */

.page-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 500;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs a.tab-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.book-page-description {
  white-space: pre-line;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.book-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin: 1.5rem 0 0;
  font-variant-numeric: tabular-nums;
}

.book-details dt {
  color: var(--muted);
}

.book-details dd {
  margin: 0;
}

.admin-box {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.admin-box p {
  margin: 0 0 0.5rem;
}

.admin-box .admin-box-sources {
  margin: 0.75rem 0 0;
}

@media (max-width: 700px) {
  .book-page {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .book-page-cover {
    max-width: 220px;
  }
  .book-page-title {
    font-size: 1.6rem;
  }
  .book-band-wrap {
    padding: 1rem 1rem 0;
  }
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.tag-chip {
  display: inline-block;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.65rem;
  font-size: 0.75rem;
  text-decoration: none;
  white-space: nowrap;
}

a.tag-chip:hover {
  background: var(--border);
}

.tag-chip-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.status-badge {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-waiting {
  background: var(--neutral-bg);
  color: var(--muted);
}

.status-processing {
  background: var(--info-bg);
  color: var(--info);
}

.status-confirmed {
  background: var(--success-bg);
  color: var(--success);
}

.status-uncertain {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-duplicate {
  background: var(--info-bg);
  color: var(--info);
}

.status-failed {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Browse */

.browse {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}

.browse-results {
  min-width: 0;
}

.browse-filters h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  margin: 0;
  font-weight: 500;
}

.browse-filters-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.browse-filters-close,
.browse-filters-open {
  display: none;
}

.facet {
  margin-bottom: 1.5rem;
}

.facet h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

.facet-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.facet-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  min-height: 36px;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.facet-option:hover {
  background: var(--surface-2);
}

.facet-option-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facet-option-count {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.facet-option-active {
  background: var(--accent);
  color: var(--on-accent);
}

.facet-option-active:hover {
  background: var(--accent);
}

.facet-option-active .facet-option-count {
  color: var(--on-accent);
  opacity: 0.8;
}

.facet-more summary {
  min-height: 36px;
  padding: 0.4rem 0.5rem;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
}

.browse-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.browse-count {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 500;
  margin: 0;
  margin-right: auto;
  font-variant-numeric: tabular-nums;
}

.sort-links {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.85rem;
}

.sort-links a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 0.75rem;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  white-space: nowrap;
}

@media (max-width: 700px) {
  .browse-toolbar {
    min-width: 0;
  }
  .sort-links {
    order: 3;
    flex: 1 0 100%;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sort-links::-webkit-scrollbar {
    display: none;
  }
}

.sort-links a + a {
  border-left: 1px solid var(--border);
}

.sort-links a.sort-active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.active-filters-clear {
  font-size: 0.85rem;
  margin-left: 0.25rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  margin-top: 2.5rem;
  font-variant-numeric: tabular-nums;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.6rem;
  border-radius: var(--radius);
  text-decoration: none;
}

.pagination a:hover {
  background: var(--surface-2);
}

.pagination-current {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.pagination-gap {
  color: var(--muted);
}

/* Under 900px the sidebar becomes a full-screen panel, opened by the
   Filters link (#filters :target) and closed by linking away. */
@media (max-width: 899px) {
  .browse {
    grid-template-columns: 1fr;
  }
  .browse-filters {
    display: none;
  }
  .browse-filters:target {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 100;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    background: var(--bg);
  }
  .browse-filters-close,
  .browse-filters-open {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    text-decoration: none;
  }
}

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

/* Admin layout: panels holding a heading, a muted line, then controls. */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel > h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 0.35rem;
}

.panel > h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 500;
  margin: 1.75rem 0 0.35rem;
}

.panel-intro {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.panel p:last-child {
  margin-bottom: 0;
}

.panel-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.panel-danger > h2 {
  color: var(--danger);
}

/* Result lines inside a panel. */
.notice,
.notice-error {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.notice {
  background: var(--success-bg);
  color: var(--success);
}

.notice-error {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Forms: left-aligned, label above field, actions in a row at the end. */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 420px;
  margin: 0;
}

.form-stack.form-wide {
  max-width: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field > label {
  font-size: 0.9rem;
  font-weight: 600;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Fields side by side (series and its number); stacked on a phone. */
.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.field-row > .field {
  flex: 1 1 14rem;
}

.field-row > .field-number {
  flex: 0 1 7rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* A field and its button on one line (bol.com link, cover upload). */
.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.form-inline > input[type="url"],
.form-inline > input[type="text"] {
  flex: 1 1 16rem;
  width: auto;
}

/* Read by screen readers, not shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.review-card-tools {
  margin-top: 1rem;
}

/* A running long job's progress bar (_ui.html job_progress). */
.check-progress progress {
  display: block;
  width: 100%;
  height: 0.75rem;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
}

.check-progress progress::-webkit-progress-bar {
  background: var(--surface-2);
}

.check-progress progress::-webkit-progress-value {
  background: var(--accent);
  transition: width 0.4s ease;
}

.check-progress progress::-moz-progress-bar {
  background: var(--accent);
}

.check-progress-text {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.review-progress {
  margin: 0 0 1.5rem;
}

/* The browser's own file button speaks the browser's language; this label
   stands in for it, the real input sits hidden inside. */
.file-pick:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.file-pick-name {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Download and Delete under the edit form, apart from Save/Confirm. */
.review-card-more {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.review-card-more .row-action {
  margin-left: 0;
}

.missing-covers .copy-button {
  display: flex;
  width: fit-content;
  margin-top: 0.4rem;
}

.review-card-body .form-stack {
  margin-top: 1.25rem;
}

.key-state {
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.key-state code {
  font-size: 0.9em;
}

.key-ok {
  color: var(--success);
}

.key-warn {
  color: var(--warning);
}

.key-failed {
  color: var(--danger);
}

.how-to {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.how-to summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.how-to ol {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
  line-height: 1.6;
  /* Real reading text (numbered steps): kept to a comfortable line length. */
  max-width: 100ch;
}

.how-to li + li {
  margin-top: 0.4rem;
}

.how-to ol ul {
  margin: 0.35rem 0;
  padding-left: 1.25rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}

/* The one centred form. */
.auth-card {
  max-width: 380px;
  margin: 3rem auto;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.auth-card h1 {
  font-family: var(--font-heading);
  font-weight: 500;
  margin: 0 0 1.25rem;
}

.auth-card .form-stack {
  max-width: none;
}

/* Tables. */
.table-wrap {
  overflow-x: auto;
  /* Keeps a .visually-hidden header label (absolute) inside the scroll
     box; otherwise it widens the whole page on a phone. */
  position: relative;
}

/* Scrolling sideways also clips vertically: a Delete… panel opened under
   the last row (the only row, say) would sit inside the box, behind a
   scroll. While one is open the box makes room for it below the table,
   and keeps scrolling sideways on a phone. */
.table-wrap:has(.row-action[open]) {
  padding-bottom: 11rem;
}

/* Within the box's visible width on a phone. */
.table-wrap .row-action-panel {
  width: min(340px, 70vw);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  text-align: left;
  padding: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table .actions {
  text-align: right;
  white-space: nowrap;
}

/* Per-row actions that open a small panel under their button (no JS). */
.row-action {
  position: relative;
  display: inline-block;
  margin-left: 0.35rem;
  text-align: left;
}

.row-action > summary {
  list-style: none;
}

.row-action > summary::-webkit-details-marker {
  display: none;
}

.row-action[open] > summary {
  background: var(--surface-2);
}

.row-action-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 20;
  width: min(340px, 85vw);
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-menu);
  white-space: normal;
  font-size: 0.9rem;
}

.row-action-panel p {
  margin: 0 0 0.75rem;
}

.data-table .actions > button {
  margin-left: 0.35rem;
}

.users-guard-note {
  margin: 0.75rem 0 0;
}

/* Phones: each user becomes a block — name, role and last login on one
   line, the action buttons wrapping underneath, panels opening leftwards. */
@media (max-width: 700px) {
  .users-table thead,
  .users-created {
    display: none;
  }
  .users-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
  }
  .users-table tr:last-child {
    border-bottom: none;
  }
  .users-table td {
    padding: 0;
    border: none;
  }
  .users-table td[data-label]::before {
    content: attr(data-label) " ";
    color: var(--muted);
  }
  .users-table td.actions {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
    text-align: left;
    white-space: normal;
  }
  .users-table .row-action,
  .users-table .actions > button {
    margin-left: 0;
  }
  .users-table .row-action-panel {
    right: auto;
    left: 0;
  }
}

/* Only the small one-button forms sitting straight in the cell (Retry,
   Discard) run inline; a form inside a row panel keeps its stack layout. */
.data-table .actions > form {
  display: inline;
}

.data-table .actions > form + form {
  margin-left: 0.35rem;
}

/* Missing covers: two forms per row (upload, bol.com link) stacked in a
   wide actions cell; on phones each book becomes a block with the forms
   underneath. */
.missing-covers .actions {
  width: 55%;
  white-space: normal;
  text-align: left;
}

.data-table.missing-covers .actions > form {
  display: flex;
  margin: 0;
}

.data-table.missing-covers .actions > form + form {
  margin: 0.5rem 0 0;
}

/* A cover found on bol.com, waiting for Use this cover / Discard. */
.pending-cover {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin: 0 0 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.pending-cover img {
  width: 96px;
  height: auto;
  flex: none;
  border-radius: 4px;
  box-shadow: var(--cover-shadow);
}

.pending-cover-body p {
  margin: 0 0 0.5rem;
}

.pending-cover-body form {
  display: inline-flex;
  margin: 0 0.35rem 0.35rem 0;
}

.missing-covers input[type="file"] {
  flex: 1 1 12rem;
  min-width: 0;
  font-size: 0.85rem;
}

@media (max-width: 700px) {
  .missing-covers thead {
    display: none;
  }
  .missing-covers tr {
    display: block;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
  }
  .missing-covers tr:last-child {
    border-bottom: none;
  }
  .missing-covers td {
    display: block;
    width: auto;
    padding: 0.15rem 0;
    border: none;
  }
  .missing-covers .actions {
    width: auto;
    margin-top: 0.5rem;
  }
}

.inline-form {
  display: inline;
  margin-right: 0.5rem;
}

.review-card {
  display: flex;
  gap: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.review-card-cover {
  flex: 0 0 140px;
}

.review-card-cover img {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
}

.review-card-cover-placeholder {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--surface-2);
  border: 1px dashed var(--placeholder-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 0.5rem;
}

.review-card-body {
  flex: 1;
  min-width: 0;
}

.review-card-body h2 {
  font-family: var(--font-heading);
  margin: 0 0 0.15rem;
}

.review-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.review-reason {
  font-size: 0.85rem;
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  margin: 0.5rem 0 0;
}

@media (max-width: 640px) {
  .review-card {
    flex-direction: column;
  }
  .review-card-cover {
    flex-basis: auto;
    max-width: 140px;
  }
}

.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--muted);
}

.empty-state p {
  margin: 0;
}

.empty-state .button-primary,
.empty-state .button-secondary {
  margin-top: 0.5rem;
}

.empty-state-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 0.35rem;
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th,
table td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.metadata-status {
  font-variant-numeric: tabular-nums;
}

/* Duplicates page */
.duplicate-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.duplicate-group-head h2 {
  margin: 0;
}

/* The button keeps its own column on the right, so a longer suggestion
   wraps beside it instead of pushing it onto a new line. */
.duplicate-suggestion {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--success-bg);
  color: var(--success);
}

.duplicate-suggestion p {
  margin: 0;
}

.duplicate-suggestion button {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .duplicate-suggestion {
    grid-template-columns: 1fr;
    justify-items: start;
  }
}

.duplicate-differ {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--warning-bg);
  color: var(--warning);
}

.duplicate-copies {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.duplicate-copy {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.duplicate-copy-suggested {
  border-color: var(--success);
}

.duplicate-copy-cover {
  flex: 0 0 96px;
}

.duplicate-copy-cover a {
  color: inherit;
  text-decoration: none;
}

@media (max-width: 700px) {
  .duplicate-copy-cover {
    flex-basis: 64px;
  }
}

/* A column, so the Keep / Delete buttons sit at the bottom of every card
   and line up across the copies, whatever the text above them. */
.duplicate-copy-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* The title in the file name, when it differs from the book's (a file
   with another book's metadata copied in). */
.duplicate-file-name {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 0.9rem;
}

.duplicate-file-name .fill-button {
  margin-left: 0.5rem;
}

.duplicate-edit {
  margin-top: 0.75rem;
}

.duplicate-edit > summary {
  list-style: none;
  display: inline-flex;
}

.duplicate-edit > summary::-webkit-details-marker {
  display: none;
}

.duplicate-edit-body {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.duplicate-edit-body > p {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}

.duplicate-copy-actions {
  margin-top: auto;
}

.duplicate-copy-body h3 {
  margin: 0;
  font-size: 1.05rem;
}

.duplicate-copy-body h3 a {
  color: inherit;
  text-decoration: none;
}

.duplicate-copy-body p {
  margin: 0.15rem 0;
}

.duplicate-copy-id {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.duplicate-compare {
  font-size: 0.85rem;
  font-weight: 600;
}

.duplicate-compare-same {
  color: var(--success);
}

.duplicate-compare-diff {
  color: var(--warning);
}

.duplicate-copy .book-details {
  margin: 0.75rem 0;
  padding-top: 0.75rem;
}

.duplicate-copy .book-details dd {
  overflow-wrap: anywhere;
}

.duplicate-copy .row-action {
  margin-left: 0;
}

.duplicate-copy .row-action-panel {
  right: auto;
  left: 0;
}

/* Download in the home-screen app on iOS (download.js): only when the
   share sheet needs one more tap, or the download failed. */
.download-dialog {
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.download-dialog::backdrop {
  background: var(--backdrop);
}

.download-dialog-message {
  margin: 0 0 1rem;
}

.download-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
