:root {
  --color-bg: #FAF7F2;
  --color-text: #2B2420;
  --color-accent: #8B5E34;
  --font-heading: Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, sans-serif;
  --color-surface: #FFFFFF;
  --color-border: #E5DDD0;
  --color-muted: #6B6258;
  --color-cover-bg: #F1E9DD;
  --shadow-cover: 0 1px 2px rgba(43, 36, 32, 0.12), 0 4px 12px rgba(43, 36, 32, 0.10);
  --radius: 6px;
  --color-accent-dark: #74502C;
  --color-danger: #B3261E;
  --color-danger-dark: #8F1E17;
  --color-danger-bg: #FDF3F1;
  --color-danger-border: #E3B3A9;
  --color-success: #2F6B32;
  --color-success-bg: #EAF3EA;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
}

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

/* 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(--color-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(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-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: 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='%236B6258' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

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

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

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

.develop-banner {
  position: fixed;
  top: 26px;
  left: -52px;
  width: 200px;
  transform: rotate(-45deg);
  background: rgba(139, 94, 52, 0.5);
  color: rgba(255, 255, 255, 0.95);
  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-heading);
  border-bottom: 1px solid var(--color-border);
}

/* 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 {
  font-size: 1.25rem;
  color: var(--color-text);
  text-decoration: none;
}

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

.brand-version {
  font-family: var(--font-body);
}

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

.header-search input {
  width: 100%;
  min-height: 40px;
  padding: 0 0.9rem;
  font: inherit;
  font-family: var(--font-body);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-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: 44px;
  padding: 0 0.75rem;
  color: var(--color-accent);
  text-decoration: none;
  cursor: pointer;
}

/* Dropdown menus are plain <details>: no JS. */
.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(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(43, 36, 32, 0.12);
  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(--color-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

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

.badge {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 0.4em;
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4em;
  text-align: center;
}

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

.site-footer a {
  color: var(--color-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:hover .book-cover,
.book-card:focus-visible .book-cover {
  transform: translateY(-2px);
}

/* 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: 3px;
  background: var(--color-cover-bg);
  box-shadow: var(--shadow-cover);
  transition: transform 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: 12% 10%;
  text-align: center;
  font-family: var(--font-heading);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}

.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: var(--color-muted);
}

.book-card-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  line-height: 1.25;
  margin: 0.65rem 0 0.15rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card-author {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-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: 50%;
  background: rgba(250, 247, 242, 0.92);
  color: var(--color-accent);
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(43, 36, 32, 0.25);
}

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

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

/* Discover */

.featured {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
  padding: 1.75rem;
  margin-bottom: 2.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

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

.featured-title {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  line-height: 1.2;
  margin: 0 0 0.25rem;
}

.featured-title a {
  color: var(--color-text);
  text-decoration: none;
}

.featured-author {
  margin: 0 0 0.85rem;
  color: var(--color-muted);
}

.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;
}

.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.3rem;
  font-weight: normal;
  margin: 0 auto 0 0;
}

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

.shelf-see-all {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.9rem;
  text-decoration: none;
}

/* 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: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.shelf-nav-button:hover:not(:disabled) {
  border-color: var(--color-accent);
  color: var(--color-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, rgba(250, 247, 242, 0), var(--color-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;
}

@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 */

.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: 2rem;
  line-height: 1.2;
  margin: 0 0 0.35rem;
}

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

.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(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

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

.button-secondary {
  background: var(--color-surface);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.button-secondary:hover {
  background: var(--color-cover-bg);
}

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

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

/* 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: var(--color-cover-bg);
  border-color: var(--color-border);
  color: var(--color-text);
}

.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(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

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

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

.rating-buttons form {
  margin: 0;
}

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

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

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

.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.6rem;
  font-weight: normal;
  margin: 0 0 1rem;
}

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

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

.tabs a.tab-active {
  color: var(--color-text);
  border-bottom-color: var(--color-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(--color-border);
  padding-top: 1rem;
  margin: 1.5rem 0 0;
}

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

.book-details dd {
  margin: 0;
}

.admin-box {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 1px dashed var(--color-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;
  }
}

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

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

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

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

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

.status-waiting {
  background: #eee6d8;
  color: var(--color-muted);
}

.status-processing {
  background: #dbe8f2;
  color: #2c5a80;
}

.status-confirmed {
  background: #dcecdc;
  color: #2f6b32;
}

.status-uncertain {
  background: #fbf3e3;
  color: #8a6d3b;
}

.status-failed {
  background: #f6dedb;
  color: #b3261e;
}

/* Browse */

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

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

.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(--color-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(--color-text);
  text-decoration: none;
  font-size: 0.9rem;
}

.facet-option:hover {
  background: var(--color-cover-bg);
}

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

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

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

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

.facet-option-active .facet-option-count {
  color: rgba(255, 255, 255, 0.8);
}

.facet-more summary {
  min-height: 36px;
  padding: 0.4rem 0.5rem;
  color: var(--color-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: normal;
  margin: 0;
  margin-right: auto;
}

.sort-links {
  display: flex;
  border: 1px solid var(--color-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(--color-text);
  text-decoration: none;
  background: var(--color-surface);
}

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

.sort-links a.sort-active {
  background: var(--color-text);
  color: var(--color-bg);
}

.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;
}

.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(--color-cover-bg);
}

.pagination-current {
  background: var(--color-text);
  color: var(--color-bg);
}

.pagination-gap {
  color: var(--color-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(--color-bg);
  }
  .browse-filters-close,
  .browse-filters-open {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    text-decoration: none;
  }
}

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

/* Admin layout: panels holding a heading, a muted line, then controls. */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-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: normal;
  margin: 0 0 0.35rem;
}

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

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

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

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

.panel-danger > h2 {
  color: var(--color-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(--color-success-bg);
  color: var(--color-success);
}

.notice-error {
  background: var(--color-danger-bg);
  color: var(--color-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(--color-muted);
}

.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;
}

.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(--color-success);
}

.key-warn {
  color: #8a6d3b;
}

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

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

.how-to summary {
  cursor: pointer;
  color: var(--color-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(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

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

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

/* Tables. */
.table-wrap {
  overflow-x: auto;
}

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

.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(--color-muted);
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--color-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(--color-cover-bg);
}

.row-action-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 20;
  width: min(340px, 85vw);
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(43, 36, 32, 0.14);
  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(--color-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(--color-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;
}

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

.review-card {
  display: flex;
  gap: 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-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: 4px;
  display: block;
}

.review-card-cover-placeholder {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--color-cover-bg);
  border: 1px dashed #d8cdb9;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9a8f7c;
  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: #8a6d3b;
  background: #fbf3e3;
  border: 1px solid #efe0bd;
  border-radius: 4px;
  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: 3rem 1rem;
  color: var(--color-muted);
}

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

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

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