:root {
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  color-scheme: light dark;
}

body {
  margin: 0;
  padding: 2rem;
  max-width: 56rem;
  margin-inline: auto;
}

body.covers-page {
  max-width: 80rem;
}

body.auth {
  display: grid;
  place-items: center;
  min-block-size: 100dvh;
}

body.auth main {
  inline-size: min(20rem, 100%);
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

form {
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.25rem;
}

input, button {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
}

button {
  cursor: pointer;
}

.error {
  color: #c33;
  margin: 0;
}

header .counter {
  margin: 0;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.shelf {
  margin-block-start: 2rem;
}

.shelf h2 {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-block-end: 0.5rem;
}

.shelf h2 .count {
  font-weight: normal;
  opacity: 0.6;
  font-size: 0.85em;
}

.book-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.book-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.5rem 0;
  border-block-end: 1px solid color-mix(in srgb, currentColor 12%, transparent);
}

.book-cover {
  width: 48px;
  height: 72px;
  object-fit: cover;
  border-radius: 2px;
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.book-cover--missing {
  display: block;
}

.book-meta {
  min-width: 0;
}

.book-meta p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-title {
  font-weight: 600;
}

.book-authors {
  opacity: 0.7;
  font-size: 0.9em;
}

.book-trailing {
  text-align: end;
  font-size: 0.85em;
}

.book-trailing p {
  margin: 0;
}

.book-date {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.book-link {
  color: inherit;
  text-decoration: none;
}

.book-link:hover {
  text-decoration: underline;
}

.back {
  margin: 0;
}

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

.back a:hover {
  text-decoration: underline;
}

.book-detail {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  margin-block-start: 2rem;
}

@media (max-width: 36rem) {
  .book-detail {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.book-detail__cover img {
  width: 200px;
  height: auto;
  border-radius: 4px;
  display: block;
}

.book-cover--large {
  width: 200px;
  height: 300px;
}

.book-detail__info h1 {
  margin: 0 0 0.25rem;
  line-height: 1.2;
}

.book-detail__authors {
  margin: 0 0 1rem;
  opacity: 0.75;
}

.book-detail__status {
  margin: 0 0 0.5rem;
  font-size: 0.95em;
}

.book-detail__status--started { color: #2a7; }
.book-detail__status--abandoned { opacity: 0.6; }

.book-detail__rating {
  margin: 0 0 1rem;
}

.book-detail__rating-num {
  opacity: 0.5;
  font-size: 0.85em;
}

.book-detail__notes {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border-inline-start: 3px solid color-mix(in srgb, currentColor 20%, transparent);
  font-style: italic;
  opacity: 0.85;
}

.book-detail__meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  margin: 0;
  font-size: 0.9em;
}

.book-detail__meta dt {
  opacity: 0.6;
}

.book-detail__meta dd {
  margin: 0;
}

.book-detail__description {
  margin-block-start: 2rem;
}

.book-detail__description p {
  white-space: pre-wrap;
}

.book-detail__history {
  margin-block-start: 2rem;
}

.book-history {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.25rem;
}

.book-history li {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  font-size: 0.9em;
}

.book-history__date {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
  min-width: 6rem;
}

.book-history__status {
  text-transform: capitalize;
}

.book-history__status--abandoned {
  opacity: 0.6;
}

.book-history__item {
  display: grid;
  gap: 0.25rem;
  padding: 0.25rem 0;
}

.book-history__summary {
  display: flex;
  gap: 1rem;
  align-items: baseline;
}

.book-history__edit summary,
.book-history__add summary {
  cursor: pointer;
  font-size: 0.85em;
  opacity: 0.6;
  list-style: none;
  user-select: none;
}

.book-history__edit summary::before,
.book-history__add summary::before {
  content: "▸ ";
}

.book-history__edit[open] summary::before,
.book-history__add[open] summary::before {
  content: "▾ ";
}

.book-history__edit summary:hover,
.book-history__add summary:hover {
  opacity: 1;
}

.book-history__add {
  margin-block-start: 1.5rem;
}

.event-form {
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-block-start: 0.5rem;
  border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, currentColor 3%, transparent);
}

.event-form__row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

@media (max-width: 30rem) {
  .event-form__row {
    grid-template-columns: 1fr;
  }
}

.event-form label {
  display: grid;
  gap: 0.15rem;
}

.event-form label > span {
  font-size: 0.8em;
  opacity: 0.6;
}

.event-form textarea {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  resize: vertical;
}

.event-form select {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
}

.event-form__buttons {
  display: flex;
  gap: 0.5rem;
}

.event-form button.danger {
  border-color: #c33;
  color: #c33;
  margin-inline-start: auto;
}

.event-form button.ghost {
  border-color: transparent;
  opacity: 0.6;
}

.event-form button.ghost:hover {
  opacity: 1;
}

.muted {
  opacity: 0.6;
}

.book-history__has-notes {
  font-size: 0.85em;
}

.header-add {
  margin: 0;
  font-size: 0.9em;
}

.header-add a {
  color: inherit;
  text-decoration: none;
  opacity: 0.8;
}

.header-add a:hover {
  opacity: 1;
  text-decoration: underline;
}

.add-scrape {
  margin-block-start: 1.5rem;
}

.add-scrape-form {
  display: flex;
  gap: 0.5rem;
  align-items: end;
}

.add-scrape-form label {
  flex: 1;
}

hr {
  border: none;
  border-block-start: 1px solid color-mix(in srgb, currentColor 15%, transparent);
  margin-block: 2rem;
}

.add-form {
  display: grid;
  gap: 0.85rem;
}

.add-form h2 {
  margin-block: 1rem 0;
  font-size: 1.1em;
}

.add-form label {
  display: grid;
  gap: 0.2rem;
}

.add-form label > span {
  font-size: 0.85em;
  opacity: 0.7;
}

.add-form label > span small {
  opacity: 0.7;
}

.add-form label > span em {
  font-style: normal;
  color: #c33;
}

.add-form input,
.add-form select,
.add-form textarea {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  width: 100%;
  box-sizing: border-box;
}

.add-form textarea {
  resize: vertical;
}

.add-form__row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

@media (max-width: 36rem) {
  .add-form__row {
    grid-template-columns: 1fr;
  }
}

.add-form__buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-block-start: 1rem;
}

.button-link {
  color: inherit;
  text-decoration: none;
  opacity: 0.6;
  padding: 0.5rem 0.75rem;
}

.button-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.book-detail__edit-book {
  margin-block-start: 2rem;
}

.book-detail__edit-book summary {
  cursor: pointer;
  font-size: 0.9em;
  opacity: 0.6;
  list-style: none;
  user-select: none;
}

.book-detail__edit-book summary::before {
  content: "▸ ";
}

.book-detail__edit-book[open] summary::before,
.book-detail__edit-book details[open] summary::before {
  content: "▾ ";
}

.book-detail__edit-book summary:hover {
  opacity: 1;
}

.book-detail__edit-book .add-form {
  margin-block-start: 1rem;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
  border-radius: 4px;
}

.add-form button.ghost {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.6;
}

.add-form button.ghost:hover {
  opacity: 1;
}

.add-form button.danger {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid #c33;
  background: transparent;
  color: #c33;
  cursor: pointer;
  margin-inline-start: auto;
}

.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.cover-card {
  display: block;
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  overflow: hidden;
  background: color-mix(in srgb, currentColor 8%, transparent);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.cover-card:hover,
.cover-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px color-mix(in srgb, currentColor 20%, transparent);
}

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

.cover-card__image--missing {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.85em;
  opacity: 0.7;
}

.cover-card__placeholder-title {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
