.book-frame {
  container-type: inline-size;
}

.book-frame__img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-frame__badge {
  z-index: 2;
}

.book-frame.is-broken .book-frame__img {
  display: none;
}

.book-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 40px 10% 11% 16%;
  overflow: hidden;
  color: #F1F5F4;
  background: linear-gradient(180deg, var(--book-tone-top), var(--book-tone-bottom));
}

.book-cover::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 7%;
  width: 2px;
  background: rgba(255, 255, 255, .14);
}

.book-cover::after {
  content: "";
  position: absolute;
  right: 10%;
  bottom: 8%;
  left: 16%;
  height: 1px;
  background: rgba(255, 255, 255, .2);
}

.book-cover__title {
  display: -webkit-box;
  overflow: hidden;
  font-size: clamp(11px, 11cqi, 22px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
}

.book-cover__author {
  overflow: hidden;
  color: rgba(241, 245, 244, .72);
  font-size: clamp(9px, 7.5cqi, 14px);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-cover--tone-0 { --book-tone-top: #2F5751; --book-tone-bottom: #1E3733; }
.book-cover--tone-1 { --book-tone-top: #4B6B6B; --book-tone-bottom: #2E4545; }
.book-cover--tone-2 { --book-tone-top: #6A5640; --book-tone-bottom: #3F3326; }
.book-cover--tone-3 { --book-tone-top: #48546A; --book-tone-bottom: #2C3443; }
.book-cover--tone-4 { --book-tone-top: #6B4646; --book-tone-bottom: #412B2B; }

.book-tile__meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.book-tile__likes {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.book-tile__likes .icon {
  color: var(--text-muted);
}

.book-tile__author {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.library__toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.library__search {
  flex: 1;
  min-width: 0;
}

.library__sort {
  align-self: flex-start;
}

.library__genres {
  margin: 0 calc(-1 * var(--gutter));
  padding: 0 var(--gutter) 2px;
}

.library__results {
  min-height: 240px;
  transition: opacity var(--dur) var(--ease);
}

.library__results[aria-busy="true"] {
  opacity: .55;
}

.library__grid {
  margin-top: 4px;
}

@media (min-width: 600px) {
  .library__toolbar {
    flex-direction: row;
    align-items: center;
  }

  .library__sort {
    align-self: auto;
  }
}

@media (min-width: 768px) {
  .library__genres {
    margin: 0;
    padding: 0 0 2px;
  }
}

.book-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.book-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  padding: 20px 16px;
}

.book-hero__cover {
  width: 168px;
  margin: 0 auto;
}

.book-frame--hero {
  display: block;
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .38);
}

a.book-frame--hero {
  cursor: zoom-in;
}

.book-hero__info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-align: center;
}

.book-hero__genre {
  align-self: center;
}

.book-hero__title {
  font-size: var(--fs-24);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}

.book-hero__uploader {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-align: left;
}

.book-hero__uploader-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.book-hero__added {
  color: var(--text-muted);
  font-size: var(--fs-13);
}

.book-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  margin: 6px 0 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.book-facts__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  text-align: center;
}

.book-facts__item + .book-facts__item {
  border-left: 1px solid var(--border);
}

.book-facts dt {
  color: var(--text-muted);
  font-size: var(--fs-12);
}

.book-facts dd {
  margin: 0;
  font-size: var(--fs-15);
  font-weight: 700;
  white-space: nowrap;
}

.book-hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.book-hero__actions > .btn--primary {
  flex: 1 1 140px;
}

@media (max-width: 479.98px) {
  .book-hero__actions {
    flex-wrap: nowrap;
  }

  .book-hero__actions > .btn--primary {
    flex: 1 1 auto;
    min-width: 0;
  }

  .book-hero__download {
    width: 40px;
    padding: 0;
  }

  .book-hero__download-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
}

.book-hero__missing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: var(--fs-14);
}

.book-like-form {
  display: inline-flex;
}

.book-like {
  min-width: 72px;
  font-variant-numeric: tabular-nums;
}

.book-like[aria-pressed="true"] {
  color: var(--like);
}

.book-like[aria-pressed="true"] .icon {
  fill: currentColor;
  animation: ml-like-pop 380ms var(--ease-out);
}

@media (min-width: 600px) {
  .book-hero {
    grid-template-columns: 196px minmax(0, 1fr);
    gap: 24px;
    padding: 24px;
  }

  .book-hero__cover {
    width: auto;
    margin: 0;
  }

  .book-hero__info {
    align-items: flex-start;
    text-align: left;
  }

  .book-hero__genre {
    align-self: flex-start;
  }

  .book-hero__actions {
    justify-content: flex-start;
    margin-top: auto;
  }

  .book-hero__actions > .btn--primary {
    flex: 0 0 auto;
  }
}

.book-about__text {
  color: var(--text);
}

.book-more {
  margin-top: 8px;
}

.book-form {
  padding: 16px;
}

.book-form__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

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

.book-form__cover {
  align-items: center;
}

.book-form__cover .field__help {
  max-width: 220px;
  text-align: center;
}

.book-form__remove {
  margin-top: 4px;
}

.cover-picker {
  position: relative;
  display: block;
  width: 150px;
  cursor: pointer;
}

.cover-picker__input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.cover-picker__frame {
  display: block;
  border: 1px dashed var(--border-strong);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.cover-picker:hover .cover-picker__frame {
  border-color: rgba(225, 227, 230, .32);
}

.cover-picker:focus-within .cover-picker__frame {
  border-color: var(--focus);
  box-shadow: var(--focus-ring);
}

.field--invalid .cover-picker__frame {
  border-color: var(--danger);
}

.cover-picker__empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  color: var(--text-secondary);
  font-size: var(--fs-13);
  font-weight: 600;
  text-align: center;
}

.cover-picker__empty .icon {
  color: var(--cyan);
}

.cover-picker__change {
  position: absolute;
  right: 6px;
  bottom: 6px;
  left: 6px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  border-radius: var(--r-full);
  background: rgba(16, 22, 22, .76);
  color: var(--text);
  font-size: var(--fs-12);
  font-weight: 600;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.cover-picker__frame:has(.cover-picker__empty:not([hidden])) .cover-picker__change {
  display: none;
}

@media (min-width: 600px) {
  .book-form {
    padding: 20px;
  }

  .book-form__layout {
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 24px;
  }

  .book-form__cover {
    align-items: flex-start;
  }

  .book-form__cover .field__help {
    text-align: left;
  }

  .cover-picker {
    width: 100%;
  }
}

.file-drop {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-input);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.file-drop:hover,
.file-drop.is-dragover {
  border-color: rgba(34, 185, 156, .6);
  background: rgba(34, 185, 156, .06);
}

.file-drop:focus-within {
  border-color: var(--focus);
  box-shadow: var(--focus-ring);
}

.field--invalid .file-drop {
  border-color: var(--danger);
}

.file-drop.has-file {
  border-style: solid;
}

.file-drop__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-drop__icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--cyan);
}

.file-drop__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.file-drop__title {
  overflow: hidden;
  color: var(--text);
  font-size: var(--fs-14);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-drop__hint {
  color: var(--text-muted);
  font-size: var(--fs-12);
}

.book-form__note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: var(--fs-13);
  line-height: 1.45;
}

.book-form__note .icon {
  margin-top: 1px;
}

.upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.upload-progress__track {
  position: relative;
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: var(--r-full);
  background: var(--surface-2);
}

.upload-progress__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--link);
  transition: width 200ms linear;
}

.upload-progress__text {
  min-width: 96px;
  color: var(--text-secondary);
  font-size: var(--fs-13);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
