* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background-color: #f6f1e8;
  color: #172033;
}

button,
input {
  font: inherit;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 24px 48px;
  background-color: #0f1b2a;
}

main {
  position: relative;
  isolation: isolate;
  min-height: calc(100vh - 88px);
  overflow: hidden;
}

main::before {
  position: absolute;
  z-index: -1;
  inset: 0;

  background-image: url("images/botanical-background-no-fruit.png");
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: cover;

  opacity: 0.2;
  pointer-events: none;

  content: "";
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.library-header-icon {
  width: 40px;
  height: 40px;
}

.page-title {
  color: #f8f3ea;
  font-size: 2rem;
  letter-spacing: 0.5px;
}

.add-new-book-btn {
  padding: 12px 22px;

  border: 0;
  border-radius: 6px;

  background-color: #e8c48f;
  color: #182233;

  font-weight: 700;
  cursor: pointer;
}

.add-new-book-btn:hover {
  filter: brightness(0.97);
}

.library-header {
  display: flex;
  align-items: center;
  gap: 14px;

  padding: 48px 48px 0;
}

.three-books-icon {
  width: 34px;
  height: 34px;
}

.books-section-title {
  color: #172033;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.5px;
}

.books-count {
  padding: 8px 14px;

  border-radius: 8px;

  background-color: #eee3d2;
  color: #6f6254;

  font-size: 0.95rem;
  font-weight: 600;
}

.library-container {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;

  width: 100%;
  max-width: 1600px;

  margin: 0 auto;
  padding: 36px 48px;
}

.book-card {
  display: flex;
  flex-direction: column;

  min-width: 0;
  padding: 18px;

  border: 1px solid rgba(214, 198, 168, 0.45);
  border-radius: 10px;

  background-color: #fffaf2;
  color: #172033;

  box-shadow: 0 8px 20px rgba(15, 27, 42, 0.12);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.book-card:hover {
  border-color: rgba(196, 166, 116, 0.65);
  box-shadow: 0 12px 26px rgba(15, 27, 42, 0.15);
  transform: translateY(-2px);
}

.book-main {
  display: grid;
  flex: 1;
  grid-template-columns: 125px minmax(0, 1fr);
  gap: 18px;
}

.book-cover {
  display: block;

  width: 125px;
  height: 188px;

  border-radius: 5px;
  border: 1px solid rgba(214, 198, 168, 0.55);

  object-fit: cover;
  background-color: #eee3d2;

  box-shadow: 0 6px 14px rgba(15, 27, 42, 0.2);
}

.book-information {
  display: flex;
  flex-direction: column;

  min-width: 0;
}

.top-group {
  display: flex;
  flex-direction: column;
  gap: 12px;

  min-height: 0;
  padding-bottom: 18px;

  border-bottom: 1px dotted #e6dccd;
}

.book-title {
  color: #172033;

  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;

  overflow-wrap: anywhere;
}

.author-group,
.pages-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-icon,
.pages-icon {
  width: 18px;
  height: 18px;

  flex-shrink: 0;
}

.book-author {
  color: #6b6b6b;

  font-size: 0.92rem;
  line-height: 1.4;
}

.book-pages {
  color: #6b6b6b;
  font-size: 0.9rem;
}

.book-status {
  display: flex;
  align-items: center;
  gap: 10px;

  width: fit-content;
  padding: 7px 11px;

  border-radius: 10px;

  font-size: 0.88rem;
  font-weight: 700;
}

.status-icon {
  width: 18px;
  height: 18px;
}

.status-read {
  background-color: #e4f3e6;
  color: #2e7d32;
}

.status-not-read {
  background-color: #fbe3e1;
  color: #b8322c;
}

.bottom-group {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;

  margin-top: 16px;
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 32px;
  padding: 6px 10px;

  border: 0;
  border-radius: 10px;

  background-color: #f7edd2;
  color: #8b681d;

  font-size: 0.82rem;
  font-weight: 800;

  cursor: pointer;
  transition:
    background-color 160ms ease,
    transform 160ms ease;
}

.rating-badge:hover {
  background-color: #f0dfb1;
  transform: translateY(-1px);
}

.rating-badge:focus-visible {
  outline: 3px solid #e8c48f;
  outline-offset: 2px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;

  margin-top: 12px;
}

.details-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 40px;
  padding: 8px 12px;

  border: 1px solid #d6c6a8;
  border-radius: 8px;

  background-color: #fffaf2;
  color: #3f4652;

  font-size: 0.85rem;
  font-weight: 700;

  margin-right: auto;

  cursor: pointer;
  transition:
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.details-btn:hover {
  background-color: #f5ecdf;
  box-shadow: 0 4px 10px rgba(15, 27, 42, 0.1);
  transform: translateY(-1px);
}

.details-btn:active {
  box-shadow: none;
  transform: translateY(0);
}

.details-btn:focus-visible {
  outline: 3px solid #e8c48f;
  outline-offset: 3px;
}

.details-icon {
  width: 18px;
  height: 18px;
}

.edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 38px;
  height: 38px;

  flex-shrink: 0;

  border: 0;
  border-radius: 50%;

  background-color: #eee3d2;

  cursor: pointer;
  transition:
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.edit-btn:hover {
  background-color: #e5d5bd;
  box-shadow: 0 4px 10px rgba(15, 27, 42, 0.12);
  transform: translateY(-1px);
}

.edit-btn:active {
  box-shadow: none;
  transform: translateY(0);
}

.edit-btn:focus-visible {
  outline: 3px solid #e8c48f;
  outline-offset: 3px;
}

.edit-icon {
  display: block;

  width: 18px;
  height: 18px;

  object-fit: contain;
}

.delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 38px;
  height: 38px;

  flex-shrink: 0;

  border: 0;
  border-radius: 50%;

  background-color: #fde8e6;
  color: #c83d36;

  cursor: pointer;
  transition:
    background-color 160ms ease,
    transform 160ms ease;
}

.delete-btn:hover {
  background-color: #fbd9d6;
  transform: translateY(-1px);
}

.delete-btn:active {
  transform: translateY(0);
}

.delete-btn:focus-visible {
  outline: 3px solid #e8c48f;
  outline-offset: 3px;
}

.bin-icon {
  display: block;

  width: 20px;
  height: 20px;

  object-fit: contain;
}

.modal-overlay,
.edit-modal-overlay,
.details-modal-overlay,
.rating-modal-overlay {
  display: none;

  position: fixed;
  inset: 0;
  z-index: 20;

  place-items: center;

  padding: 24px;

  background-color: rgba(15, 27, 42, 0.55);
}

.modal-overlay.active,
.edit-modal-overlay.active,
.details-modal-overlay.active,
.rating-modal-overlay.active {
  display: grid;
}

.rating-modal {
  position: relative;

  width: 100%;
  max-width: 430px;
  padding: 34px;

  border: 1px solid rgba(214, 198, 168, 0.65);
  border-radius: 14px;

  background-color: #fffaf2;
  text-align: center;

  box-shadow: 0 18px 45px rgba(15, 27, 42, 0.28);
}

.close-rating-btn {
  position: absolute;
  top: 18px;
  right: 18px;

  display: grid;
  place-items: center;

  width: 36px;
  height: 36px;

  border: 1px solid #d6c6a8;
  border-radius: 50%;

  background-color: #fffaf2;
  color: #172033;

  font-size: 1.55rem;
  line-height: 1;

  cursor: pointer;
}

.close-rating-btn:hover {
  background-color: #f5ecdf;
}

.rating-modal-eyebrow {
  color: #8b7355;

  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.rating-modal-title {
  margin-top: 18px;
  padding-inline: 24px;

  color: #172033;

  font-size: 1.65rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.rating-modal-help {
  margin-top: 8px;

  color: #756b60;
  font-size: 0.92rem;
}

.quick-rating-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  margin-top: 24px;
}

.quick-rating-control button {
  padding: 0;

  border: 0;

  background: transparent;
  color: #cfc5b4;

  font-size: 2.5rem;
  line-height: 1;

  cursor: pointer;
  transition:
    color 140ms ease,
    transform 140ms ease;
}

.quick-rating-control button.selected,
.quick-rating-control button:hover {
  color: #d9a72c;
}

.quick-rating-control button:hover {
  transform: translateY(-2px) scale(1.08);
}

.quick-rating-control button:focus-visible {
  outline: 2px solid #d9a72c;
  outline-offset: 3px;
  border-radius: 4px;
}

.details-modal {
  width: 100%;
  max-width: 680px;
  max-height: calc(100vh - 48px);

  overflow-y: auto;

  padding: 30px;
  border-radius: 14px;

  background-color: #fffaf2;
  box-shadow: 0 18px 45px rgba(15, 27, 42, 0.28);
}

.details-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;

  margin-bottom: 24px;
}

.details-eyebrow {
  color: #8b7355;

  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.close-details-btn {
  display: grid;
  place-items: center;

  width: 38px;
  height: 38px;

  flex-shrink: 0;

  border: 1px solid #d6c6a8;
  border-radius: 50%;

  background-color: #fffaf2;
  color: #172033;

  font-size: 1.7rem;
  line-height: 1;

  cursor: pointer;
}

.close-details-btn:hover {
  background-color: #f5ecdf;
}

.details-content {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 28px;
}

.details-cover {
  width: 150px;
  height: 225px;

  border-radius: 6px;

  object-fit: cover;
  background-color: #eee3d2;

  box-shadow: 0 8px 20px rgba(15, 27, 42, 0.2);
}

.details-information {
  min-width: 0;
}

.details-title {
  color: #172033;

  font-size: 1.8rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.details-author {
  margin-top: 8px;

  color: #6f6254;
  font-size: 1.05rem;
}

.details-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;

  margin-top: 28px;
}

.details-list div {
  padding: 12px 14px;

  border-radius: 8px;

  background-color: #f5ecdf;
}

.details-list dt {
  margin-bottom: 4px;

  color: #8b7355;

  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.details-list dd {
  color: #243044;

  font-size: 0.95rem;
  font-weight: 700;
}

.details-list .details-rating-item {
  grid-column: 1 / -1;
}

.details-rating-display {
  display: flex;
  align-items: center;
  gap: 3px;
  color: #cfc5b4;

  font-size: 1.55rem;
  line-height: 1;
}

.details-rating-display span.selected {
  color: #d9a72c;
}

.details-description-section {
  margin-top: 26px;
  padding-top: 22px;

  border-top: 1px dotted #d6c6a8;
}

.details-description-section h3 {
  margin-bottom: 9px;

  color: #172033;
  font-size: 1rem;
}

.details-description {
  color: #5f5a53;

  font-size: 0.96rem;
  line-height: 1.65;
}

.book-form,
.edit-book-form {
  display: flex;
  flex-direction: column;
  gap: 24px;

  width: 100%;
  max-width: 500px;
  max-height: calc(100vh - 48px);

  overflow-y: auto;

  padding: 28px;

  border-radius: 10px;

  background-color: #fffaf2;

  box-shadow: 0 14px 35px rgba(15, 27, 42, 0.25);
}

.edit-book-form {
  max-width: 540px;
  gap: 20px;
}

.edit-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.form-title {
  margin-bottom: 8px;

  color: #172033;

  font-size: 2rem;
  font-weight: 800;
}

.edit-form-header .form-title {
  margin-bottom: 0;
}

.close-edit-btn {
  display: grid;
  place-items: center;

  width: 38px;
  height: 38px;

  flex-shrink: 0;

  border: 1px solid #d6c6a8;
  border-radius: 6px;

  background-color: #fffaf2;
  color: #172033;

  font-size: 1.8rem;
  line-height: 1;

  cursor: pointer;
}

.close-edit-btn:hover {
  background-color: #f5ecdf;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  color: #172033;

  font-size: 0.95rem;
  font-weight: 700;
}

.form-group label span {
  color: #7c7062;
  font-size: 0.85rem;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 14px 16px;

  border: 1px solid #d6c6a8;
  border-radius: 6px;

  background-color: #fffdf8;
  color: #172033;

  font-size: 1rem;
}

.form-group select {
  cursor: pointer;
}

.form-group input:focus,
.form-group select:focus {
  outline: 2px solid #e8c48f;
  outline-offset: 2px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-group input {
  width: 16px;
  height: 16px;

  cursor: pointer;
}

.checkbox-group label {
  color: #172033;

  font-size: 0.95rem;
  font-weight: 600;

  cursor: pointer;
}

.button-container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.button-container > button {
  padding: 12px 18px;

  border: 0;
  border-radius: 6px;

  font-size: 1rem;
  font-weight: 700;

  cursor: pointer;
}

.cancel-btn,
.cancel-edit-btn {
  border: 1px solid #d6c6a8 !important;

  background-color: #fffaf2;
  color: #172033;
}

.submit-book-btn,
.save-edit-btn {
  border: 1px solid #0f1b2a !important;

  background-color: #0f1b2a;
  color: #fffaf2;
}

.submit-book-btn:disabled,
.save-edit-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.bookshelf {
  width: 140px;
  height: auto;
}

.library-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;

  padding: 0 24px 40px;

  text-align: center;
}

.library-message h3 {
  color: #243044;

  font-size: 1.4rem;
  font-weight: 800;
}

.library-message p {
  color: #3f4654;
  font-size: 1rem;
}

@media (max-width: 1000px) {
  .library-container {
    grid-template-columns: repeat(3, minmax(0, 1fr));

    padding: 32px 24px;
  }

  .book-card {
    padding: 14px;
  }

  .book-main {
    grid-template-columns: 105px minmax(0, 1fr);
    gap: 14px;
  }

  .book-cover {
    width: 105px;
    height: 158px;
  }

  .book-title {
    font-size: 1.05rem;
  }

  .author-group,
  .pages-group {
    gap: 7px;
  }

  .details-btn {
    padding-inline: 10px;
  }
}

@media (max-width: 820px) {
  .library-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  main::before {
    background-position: 58% bottom;
    background-size: auto 100%;
    opacity: 0.14;
  }

  header {
    padding: 20px 24px;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .library-header-icon {
    width: 34px;
    height: 34px;
  }

  .add-new-book-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .library-header {
    padding: 36px 24px 0;
  }

  .books-section-title {
    font-size: 1.35rem;
  }

  .library-container {
    grid-template-columns: 1fr;

    padding: 28px 24px;
  }

  .book-card {
    padding: 18px;
  }

  .book-main {
    grid-template-columns: 105px minmax(0, 1fr);
    gap: 18px;
  }

  .book-cover {
    width: 105px;
    height: 158px;
  }

  .book-title {
    font-size: 1.15rem;
  }

  .book-author,
  .book-pages {
    font-size: 0.9rem;
  }

  .top-group {
    gap: 12px;
  }

  .book-status {
    padding: 7px 10px;
    font-size: 0.85rem;
  }

  .book-form,
  .edit-book-form {
    padding: 22px;
  }

  .details-modal {
    padding: 22px;
  }

  .details-content {
    grid-template-columns: 105px minmax(0, 1fr);
    gap: 18px;
  }

  .details-cover {
    width: 105px;
    height: 158px;
  }

  .details-title {
    font-size: 1.35rem;
  }

  .details-list {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 18px;
  }

  .details-list div {
    padding: 9px 11px;
  }

  .bottom-group {
    align-items: center;
  }

  .card-actions {
    flex-direction: row;
    align-items: center;
  }

}

@media (max-width: 420px) {
  .header-brand {
    gap: 10px;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .add-new-book-btn {
    padding: 9px 11px;
  }

  .book-main {
    grid-template-columns: 1fr;
  }

  .book-cover {
    width: 140px;
    height: 210px;

    justify-self: center;
  }

  .details-content {
    grid-template-columns: 1fr;
  }

  .details-cover {
    width: 140px;
    height: 210px;
    justify-self: center;
  }

  .bottom-group {
    align-items: center;
  }

  .card-actions {
    flex-direction: row;
    align-items: center;
  }
}
