/* Library */

.lib__tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.lib__filters {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.lib__levels {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}
.lib__level {
  background: var(--sand);
  color: var(--ink);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 13px;
}
.lib__level:hover { background: var(--sand-hover); color: var(--ink); text-decoration: none; }
.lib__level[aria-current="page"] { background: var(--ink); color: var(--paper); }

/* The search box: titles, authors and the words inside the books. */
.lib__filters--end { justify-content: flex-end; }
.lib__search { width: min(100%, 500px); display: flex; flex-direction: column; gap: 8px; }
.lib__search-box {
  display: flex; align-items: center; gap: 10px;
  min-height: 46px; padding-block: 0; padding-inline: 16px 6px;
  background: var(--field); border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
}
.lib__search-box:focus-within { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), 0 0 0 4px var(--green-soft); }
.lib__search-icon { flex: none; color: var(--text-muted); }
.lib__search-input {
  flex: 1; min-width: 0; height: 44px; padding: 0;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 15px; color: var(--ink);
}
.lib__search-input::placeholder { color: var(--text-muted); opacity: 1; }
.lib__search-input::-webkit-search-cancel-button { appearance: none; }
.lib__search-input:dir(rtl) { font-family: var(--font-arabic); font-size: 20px; }
.lib__search-tag {
  flex: none; padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700;
}
.lib__search-tag[hidden] { display: none; }
.lib__search-clear {
  flex: none; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: none; color: var(--text-muted); font-size: 18px; line-height: 1;
}
.lib__search-clear:hover { background: var(--sand); color: var(--ink); }
.lib__search:has(.lib__search-input:placeholder-shown) .lib__search-clear { display: none; }
.lib__search-hint { display: none; margin: 0; padding-inline-start: 16px; font-size: 13px; color: var(--text-body); }
.lib__search-hint .ar { font-size: 16px; }
.lib__search-hint-short { display: none; }
.lib__search:focus-within:has(.lib__search-input:placeholder-shown) .lib__search-hint { display: block; }

/* Tab counts while searching. */
.lib__tab { position: relative; display: inline-flex; align-items: baseline; gap: 6px; }
.lib__tab-count { font-size: 12px; font-weight: 700; opacity: .6; }
.lib__tab[aria-current="page"] .lib__tab-count { opacity: .85; }
.lib__tab.is-empty:not([aria-current="page"]) { color: var(--text-faint); }

/* "The public library" banner */
.lib__public {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 24px 26px;
}
.lib__public-text { display: flex; flex-direction: column; gap: 6px; max-width: 640px; }
.lib__public-title { font-size: 30px; line-height: 1.1; }
.lib__public-lead { font-size: 15px; line-height: 1.5; color: var(--text-on-dark-muted); }
.lib__public-ar { font-size: 42px; color: var(--peach); }

/* Upload card (a dashed button) */
.lib__upload {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 22px;
  color: var(--ink);
  text-align: var(--start);
  font: inherit;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.lib__upload:hover { background: var(--card); border-color: var(--ink); }
.lib__upload-text { display: flex; flex-direction: column; gap: 4px; flex: 1 1 220px; font-size: 14px; }
.lib__upload-title { font-size: 16px; }

/* Book cards */
.lib__card { display: flex; flex-direction: column; gap: 12px; padding: 22px; }
.lib__card-tags { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.lib__card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.lib__card-ar { font-size: 26px; line-height: 1.5; }
.lib__card-title { font-size: 24px; line-height: 1.1; }
.lib__card-author { font-size: 14px; color: var(--text-muted); margin-top: -6px; }
.lib__card-status { font-size: 14px; color: var(--clay); font-weight: 600; }
.lib__card-progress { display: flex; flex-direction: column; gap: 6px; }
.lib__card-progress .progress { flex: none; height: 5px; }
.lib__card-stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.lib__coverage { font-weight: 600; text-align: var(--end); }
.lib__coverage--high { color: var(--green); }
.lib__coverage--mid { color: color-mix(in srgb, var(--gold) 60%, var(--ink)); }
.lib__coverage--low { color: var(--clay); }

.lib__card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}
.lib__card-note { font-size: 12px; color: var(--text-muted); text-align: var(--end); }

@media (max-width: 600px) {
  .lib__search { width: 100%; order: -1; }
  .lib__search-box { min-height: 48px; padding-block: 0; padding-inline: 14px 2px; gap: 8px; }
  .lib__search-tag { padding: 4px 8px; font-size: 11px; }
  .lib__search-clear { width: 44px; height: 44px; font-size: 20px; }
  .lib__search-hint { padding: 0 6px; }
  .lib__search-hint-more { display: none; }
  .lib__search-hint-short { display: inline; }
}

.lib__card-description { margin: -4px 0 0; font-size: 14px; line-height: 1.5; color: var(--text-body); }
.lib__card-reason { margin: 6px 0 0; font-size: 13px; color: var(--text-body); }

/* Uploads */
.lib__upload { cursor: default; }
.lib__upload.is-busy { opacity: .7; }
.lib__upload-busy { font-size: 14px; font-weight: 600; color: var(--green); }
.lib__upload-button { cursor: pointer; }
.lib__upload:focus-within { border-color: var(--ink); }
.lib__card-status--failed { color: var(--clay-deep); }
.lib__delete { color: var(--clay); }

/* Bookmarks & notes shelf. */
.lib__notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.lib__note { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.lib__note-link { display: flex; flex-direction: column; gap: 2px; color: var(--ink); text-decoration: none; }
.lib__note-link:hover { text-decoration: none; color: var(--clay); }
.lib__note-book { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; font-family: var(--font-serif); font-size: 22px; }
.lib__note-ar { font-size: 18px; color: var(--text-muted); }
.lib__note-meta { font-size: 13px; color: var(--text-muted); }
.lib__note-body { margin: 0; font-size: 15px; line-height: 1.5; white-space: pre-line; }

/* Graded texts shelf: a heading per CEFR level */
.lib__section-title { font-size: 26px; margin: 12px 0 -4px; scroll-margin-top: 16px; }
.lib__section-title .muted { font-family: var(--font-sans); font-size: 14px; }
.lib__section-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.lib__own-level { align-self: center; font-family: var(--font-sans); }

/* The kind of Arabic to put first: asked once above the shelves, then a note with "Change". */
.lib__section-kind { color: var(--green); }
.lib-focus {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-card);
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.lib-focus--compact { padding: 14px; margin-top: 10px; }
.lib-focus__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.lib-focus__intro { display: flex; flex-direction: column; gap: 4px; }
.lib-focus__title { margin: 0; font-weight: 400; font-size: 32px; line-height: 1.1; }
.lib-focus__lead { margin: 0; font-size: 15px; color: var(--text-on-dark-muted); }
.lib-focus__skip {
  background: none; border: 0; color: var(--text-on-dark-muted); font: inherit; font-size: 14px;
  min-height: 44px; padding: 0 4px; text-decoration: underline; cursor: pointer; flex-shrink: 0;
}
.lib-focus__skip:hover { color: var(--paper); }
.lib-focus__options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.lib-focus__option {
  background: var(--ink-raised);
  border: 1.5px solid var(--ink-line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  text-align: var(--start);
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--paper);
  font: inherit;
  cursor: pointer;
}
.lib-focus__option:hover, .lib-focus__option[aria-pressed="true"] { border-color: var(--peach); }
.lib-focus__ar { font-size: 30px; line-height: 1.4; color: var(--peach); align-self: flex-start; }
.lib-focus__name { font-size: 16px; font-weight: 700; }
.lib-focus__note { font-size: 13px; line-height: 1.4; color: var(--text-on-dark-muted); }

.lib-focus-note { align-self: stretch; }
.lib-focus-note__line {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--sand); border-radius: var(--radius-pill); padding-block: 2px; padding-inline: 16px 6px;
  font-size: 14px; color: var(--text-body); cursor: pointer; list-style: none;
}
.lib-focus-note__line::-webkit-details-marker { display: none; }
.lib-focus-note__line strong { color: var(--ink); }
.lib-focus-note__line::after { content: none; }
.lib-focus-note__change { display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px; font-weight: 600; color: var(--clay); text-decoration: underline; }
.lib-focus-note[open] .lib-focus-note__change { color: var(--ink); }

/* The shelf just moved to the top, briefly marked. */
.card-grid.is-moved { animation: lib-moved 1.2s ease-out; border-radius: var(--radius-card); }
@keyframes lib-moved { from { box-shadow: 0 0 0 6px var(--peach); background: rgba(233, 180, 143, .18); } to { box-shadow: 0 0 0 6px transparent; background: transparent; } }
@media (prefers-reduced-motion: reduce) { .card-grid.is-moved { animation: none; } }

@media (max-width: 700px) {
  .lib-focus { padding: 18px; gap: 12px; }
  .lib-focus__head { gap: 8px; }
  .lib-focus__title { font-size: 26px; }
  .lib-focus__options { grid-template-columns: 1fr; }
  .lib-focus__option { padding: 12px 14px; gap: 2px; }
  .lib-focus__ar { font-size: 24px; }
  .lib-focus__name { font-size: 15px; }
}

/* "Continue reading": the books in progress, at the top of All, ruled off from the shelves. */
.lib-continue { display: flex; flex-direction: column; gap: 12px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.lib-continue__head { display: flex; align-items: baseline; gap: 12px; }
.lib-continue__title { margin: 0; font-weight: 400; font-size: 30px; line-height: 1; }
.lib-continue__count { font-size: 14px; color: var(--text-muted); }
/* Three slots, so a lone card keeps its third rather than stretching; a fourth for "See all". */
.lib-continue__list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.lib-continue__list--more { grid-template-columns: repeat(3, minmax(0, 1fr)) 200px; }
.lib-continue__more {
  border: 1.5px dashed var(--line-dashed); border-radius: var(--radius-card); padding: 18px;
  display: flex; flex-direction: column; justify-content: center; gap: 6px; color: var(--ink);
}
.lib-continue__more:hover { background: var(--card); border-color: var(--ink); text-decoration: none; color: var(--ink); }
.lib-continue__more-n { font-size: 40px; line-height: 1; }
.lib-continue__more-label { font-size: 15px; font-weight: 700; }
.lib-continue__more-total { display: none; }
.lib-continue__more-sub { font-size: 13px; color: var(--text-muted); }

/* A book in progress (Continue reading, and Today): the whole card opens it. */
.lib-resume { position: relative; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.lib-resume:hover { border-color: var(--ink); }
.lib-resume:focus-within { border-color: var(--ink); }
.lib-resume__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lib-resume__when { font-size: 12px; color: var(--text-muted); }
.lib-resume__titles { display: flex; flex-direction: column; min-width: 0; }
.lib-resume__ar { font-size: 24px; line-height: 1.5; align-self: flex-start; }
.lib-resume__title { margin: 0; font-weight: 400; font-size: 22px; line-height: 1.1; }
.lib-resume__progress { display: flex; flex-direction: column; gap: 6px; }
.lib-resume__page { font-size: 13px; font-weight: 600; color: var(--ink-line); }
.lib-resume__foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: auto; min-height: 44px; }
.lib-resume__coverage { font-size: 13px; font-weight: 600; line-height: 1.3; }
.lib-resume__go { min-height: 44px; padding: 0 20px; flex-shrink: 0; }
.lib-resume__go::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } /* the card is the link */
.lib-resume__go:focus-visible { outline-offset: 3px; }

.progress--reading { height: 5px; flex: none; }
.lib-resume__ar { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } /* an upload's title can be a whole sentence */
.lib__card-reading { font-weight: 700; color: var(--ink); }

/* "See all in progress": the shelf filtered to books in progress. */
.lib-progress-filter {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--sand); border-radius: var(--radius-md); padding: 12px 16px; font-size: 14px;
}
.lib-progress-filter__clear { font-weight: 600; }

@media (max-width: 900px) {
  .lib-continue__list, .lib-continue__list--more { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .lib-continue__more { flex-direction: row; justify-content: center; min-height: 44px; padding: 10px 14px; border-radius: var(--radius-md); }
  .lib-continue__more-n, .lib-continue__more-sub { display: none; }
  .lib-continue__more-total { display: inline; }
}
@media (max-width: 700px) {
  .lib-continue { gap: 10px; padding-bottom: 20px; }
  .lib-continue__head { justify-content: space-between; }
  .lib-continue__title { font-size: 26px; }
  .lib-continue__count { font-size: 13px; }
  .lib-resume { padding: 14px 16px; gap: 8px; border-radius: 16px; }
  .lib-resume__ar { font-size: 20px; }
  .lib-resume__title { font-size: 21px; }
  /* The shelf tabs scroll sideways in their own row. */
  .lib__tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); max-width: 100vw; }
  .lib__tabs > * { flex-shrink: 0; white-space: nowrap; }
}

/* Search results, in place of the shelves (library/_search). */
.lib-search { display: flex; flex-direction: column; gap: 22px; }
.lib-search__summary {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.lib-search__count { margin: 0; font-size: 28px; line-height: 1.2; }
.lib-search__q { font-size: 26px; }
.lib-search__filters { font-family: var(--font-sans); font-size: 14px; color: var(--text-muted); }
.lib-search__clear { font-size: 14px; font-weight: 600; white-space: nowrap; }
.lib-search__busy { display: none; margin: 0; font-family: var(--font-serif); font-style: italic; font-size: 22px; color: var(--text-body); }
.lib-search.is-searching .lib-search__busy { display: block; }
.lib-search.is-searching > :not(.lib-search__summary, .lib-search__busy) { opacity: .45; transition: opacity .2s; }

.lib-search__group { display: flex; flex-direction: column; gap: 12px; }
.lib-search__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.lib-search__h { margin: 0; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; font-weight: 700; color: var(--text-muted); }
.lib-search__order { font-size: 13px; color: var(--text-muted); }
.lib-search__more-link { font-size: 14px; font-weight: 600; }

/* The hit, in titles and excerpts. */
.lib-hit {
  background: var(--mark); color: var(--ink); font-weight: 700; border-radius: 3px; padding: 0 2px;
  text-decoration: underline; text-decoration-color: var(--clay); text-decoration-thickness: 2px; text-underline-offset: 6px;
}

/* The dictionary word searched, and its forms. */
.lib-word {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 16px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
}
.lib-word__ar { font-size: 38px; line-height: 1.3; }
.lib-word__text { display: flex; flex-direction: column; gap: 4px; flex: 1 1 260px; min-width: 0; }
.lib-word__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lib-word__gloss { font-size: 17px; }
.lib-word__note { font-size: 13px; color: var(--text-body); }
.lib-word__note .ar { font-size: 16px; }
.lib-word__link { font-weight: 600; }
.lib-word__forms { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-form {
  display: inline-flex; align-items: center; gap: 2px; min-height: 36px; padding-block: 0; padding-inline: 12px 4px;
  background: var(--field); border: 1px solid var(--line-strong); border-radius: var(--radius-pill); color: var(--ink);
}
.lib-form__ar { font-size: 19px; line-height: 1; }
.lib-form__remove {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border-radius: 50%; color: var(--text-muted); font-size: 15px;
}
.lib-form__remove:hover { background: var(--sand); color: var(--ink); text-decoration: none; }
.lib-form--off { padding: 0 12px; background: transparent; border-style: dashed; color: var(--text-muted); gap: 6px; }
.lib-form--off:hover { color: var(--ink); border-color: var(--ink); text-decoration: none; }

/* English: the Arabic words searched, as checkboxes. */
.lib-word--english { flex-direction: column; align-items: stretch; gap: 12px; }
.lib-word__lead { margin: 0; font-size: 15px; }
.lib-english { display: flex; gap: 8px; flex-wrap: wrap; }
.lib-english__form { display: contents; }
.lib-english__word {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding-block: 6px; padding-inline: 10px 14px;
  background: transparent; border: 1.5px solid var(--line-strong); border-radius: 12px;
  color: var(--ink); font: inherit; cursor: pointer; opacity: .75;
}
.lib-english__word[aria-checked="true"] { background: var(--field); border-color: var(--ink); opacity: 1; }
.lib-english__word:hover { border-color: var(--ink); opacity: 1; }
.lib-english__box {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 18px; height: 18px;
  border: 2px solid var(--line-dashed); border-radius: 4px; color: var(--paper); font-size: 12px; font-weight: 700;
}
.lib-english__word[aria-checked="true"] .lib-english__box { border-color: var(--green); background: var(--green); }
.lib-english__ar { font-size: 22px; line-height: 1; }
.lib-english__en { font-size: 13px; color: var(--text-body); }

/* Title and author matches: one compact row. */
.lib-titles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.lib-title {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); color: var(--ink);
}
.lib-title:hover { border-color: var(--line-strong); background: var(--sand-hover); color: var(--ink); text-decoration: none; }
.lib-title__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-title__en { font-size: 20px; line-height: 1.1; }
.lib-title__meta { font-size: 12px; color: var(--text-muted); }
.lib-title__meta strong { color: var(--ink); }
.lib-title__ar { font-size: 20px; line-height: 1.4; text-align: start; }

/* Inside the books: one card per book, with lines from its pages. */
.lib-search__ocr {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 14px;
  background: var(--sand); border-radius: 12px; font-size: 14px; color: var(--ink-line);
}
.lib-search__ocr-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--gold-deep); }
.lib-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.lib-result {
  display: flex; flex-direction: column; gap: 12px; padding: 20px 24px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card);
  scroll-margin-top: 16px;
}
.lib-result__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.lib-result__titles { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lib-result__title { margin: 0; font-size: 26px; font-weight: 400; line-height: 1.1; }
.lib-result__meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); }
.lib-result__pages { color: var(--ink); font-weight: 600; }
.lib-result__ar { flex: 0 1 auto; max-width: 50%; font-size: 26px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-only {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; color: var(--ink);
}
.lib-lines { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-soft); }
.lib-lines li { border-bottom: 1px solid var(--line-soft); }
.lib-line { display: flex; align-items: center; gap: 18px; padding: 8px 6px; border-radius: 8px; color: var(--ink); }
.lib-line:hover { background: var(--sand-hover); color: var(--ink); text-decoration: none; }
.lib-line__page { flex: none; width: 58px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.lib-line__text {
  flex: 1; min-width: 0; font-size: 21px; line-height: 1.9; text-align: start;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-line__near { display: none; }
.lib-line__go { flex: none; color: var(--text-faint); font-size: 15px; }
.lib-result__toggle { align-self: flex-start; padding: 6px 2px; font-size: 14px; font-weight: 600; }
.lib-result__rest { margin: 0; font-size: 14px; color: var(--text-body); }
.lib-search__more { align-self: center; min-height: 46px; padding: 0 24px; border-width: 1.5px; font-weight: 600; }

/* No matches, or too common a word. */
.lib-search__state {
  display: flex; flex-direction: column; gap: 14px; max-width: 720px; padding: 36px 40px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card);
}
.lib-search__state p { margin: 0; font-size: 16px; line-height: 1.5; color: var(--ink-line); }
.lib-search__state .lib-search__state-title { font-size: 32px; line-height: 1.15; color: var(--ink); }
.lib-search__state .muted { font-size: 14px; color: var(--text-muted); }
.lib-search__state .ar { font-size: 1.15em; }
.lib-search__ways { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 16px; line-height: 1.5; color: var(--ink-line); }
.lib-search__ways a { font-weight: 600; }

@media (max-width: 900px) {
  .lib-titles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lib-titles:not(.is-all) .lib-title:nth-child(n + 3) { display: none; }
}

@media (max-width: 600px) {
  .lib-search { gap: 14px; }
  .lib-search__summary { gap: 10px; padding-bottom: 12px; }
  .lib-search__count { font-size: 22px; line-height: 1.25; }
  .lib-search__q { font-size: 21px; }
  .lib-search__filters { display: block; }
  .lib-search__clear { min-height: 44px; display: inline-flex; align-items: center; }
  .lib-search__clear-more { display: none; }
  .lib-search__busy { font-size: 20px; }
  .lib-search__h { font-size: 12px; }
  .lib-search__order { display: none; }
  .lib-search__ocr-names { display: none; }

  .lib-word { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 10px; padding: 14px; border-radius: var(--radius-md); }
  .lib-word__ar { grid-column: 2; grid-row: 1; font-size: 30px; }
  .lib-word__text { grid-column: 1; grid-row: 1; }
  .lib-word__forms { grid-column: 1 / -1; }
  .lib-word--english { display: flex; }
  .lib-word__gloss { font-size: 15px; }
  .lib-word__note { font-size: 12px; }
  .lib-form { min-height: 44px; padding-block: 0; padding-inline: 12px 0; }
  .lib-form__ar { font-size: 18px; }
  .lib-form__remove { width: 36px; height: 44px; border-radius: 0; }
  .lib-word__lead { font-size: 14px; }
  .lib-word__lead-more { display: none; }
  .lib-english { flex-direction: column; }
  .lib-english__word { width: 100%; padding-block: 4px; padding-inline: 10px 12px; }
  .lib-english__en { flex: 1; text-align: var(--start); }
  .lib-english__ar { order: 3; font-size: 21px; }
  .lib-english .level-pill { order: 2; }

  .lib-titles { grid-template-columns: minmax(0, 1fr); }
  .lib-titles:not(.is-all) .lib-title:nth-child(n + 2) { display: none; }
  .lib-title { padding: 12px 14px; }
  .lib-title__en { font-size: 19px; }
  .lib-title__ar { font-size: 19px; }

  .lib-result { gap: 8px; padding: 14px 14px 8px; border-radius: 16px; }
  .lib-result__head { flex-direction: column-reverse; gap: 4px; }
  .lib-result__title { font-size: 21px; }
  .lib-result__ar { font-size: 19px; align-self: flex-end; max-width: 100%; }
  .lib-result__meta { gap: 6px; font-size: 12px; }
  .lib-line { min-height: 48px; gap: 10px; padding: 4px 2px; }
  .lib-line__page { width: 46px; font-size: 12px; }
  .lib-line__text { font-size: 19px; text-overflow: clip; }
  .lib-line__far, .lib-line__go { display: none; }
  .lib-line__near { display: inline; }
  .lib-result__toggle { min-height: 44px; display: inline-flex; align-items: center; padding: 0 2px; }
  .lib-search__more { align-self: stretch; min-height: 48px; justify-content: center; }
  .lib-search__more-count { display: none; }

  .lib-search__state { padding: 20px; gap: 10px; border-radius: 16px; }
  .lib-search__state .lib-search__state-title { font-size: 26px; }
  .lib-search__ways { padding: 0; list-style: none; gap: 0; }
  .lib-search__ways li { min-height: 44px; display: flex; align-items: center; flex-wrap: wrap; gap: 0 6px; font-size: 15px; }
}

/* Related passages: found by meaning (library/_related). Second to the word
   results: outlined cards, not filled ones. */
.lib-search__related { color: var(--green); }
.lib-related { display: flex; flex-direction: column; gap: 14px; }
.lib-related--second { border-top: 1px solid var(--line-strong); padding-top: 28px; }
.lib-related__head { display: flex; align-items: baseline; gap: 8px 14px; flex-wrap: wrap; }
.lib-related__h { margin: 0; font-size: 34px; font-weight: 400; line-height: 1; }
.lib-related--second .lib-related__h { font-size: 30px; }
.lib-related__note { font-size: 14px; color: var(--text-body); }
.lib-related__info-button {
  order: 3; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  background: none; border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.lib-related__info-button:hover, .lib-related__info-button[aria-expanded="true"] { border-color: var(--ink); }
.lib-related__info-sr { display: none; }
.lib-related__i {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
  border: 1.5px solid currentColor; border-radius: 50%;
  font-family: var(--font-serif); font-style: italic; font-size: 11px; font-weight: 700;
}
.lib-related__info { margin: 0; max-width: 760px; padding: 12px 16px; background: var(--sand); border-radius: 12px; font-size: 14px; line-height: 1.55; }
.lib-related__info-more { color: var(--ink-line); }
.lib-related__status { margin: 0; font-family: var(--font-serif); font-style: italic; font-size: 22px; color: var(--text-body); }
.lib-related__placeholder {
  display: flex; flex-direction: column; gap: 12px; padding: 20px 22px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-card);
}
.lib-related__placeholder span { height: 14px; border-radius: 6px; background: var(--line-soft); }
.lib-related__placeholder span:nth-child(1) { width: 260px; height: 18px; background: var(--sand); }
.lib-related__placeholder span:nth-child(2) { width: 150px; height: 12px; background: var(--sand); }
.lib-related__placeholder span:nth-child(3) { align-self: flex-end; width: min(600px, 80%); }
.lib-related__placeholder span:nth-child(4) { align-self: flex-end; width: min(520px, 70%); }
.lib-related__quiet { margin: 0; font-size: 15px; line-height: 1.5; color: var(--text-body); }
.lib-related__quiet .ar { font-size: 1.15em; }
.lib-related__books { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.lib-related__tier {
  display: flex; align-items: center; gap: 12px; padding-top: 6px;
  font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; font-weight: 700; color: var(--text-muted);
}
.lib-related__tier::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.lib-related__book {
  display: flex; flex-direction: column; gap: 10px; padding: 18px 22px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-card); scroll-margin-top: 16px;
}
.lib-related__title { margin: 0; font-size: 24px; font-weight: 400; line-height: 1.1; }
.lib-lines--related { border-top-color: var(--line); }
.lib-lines--related li { border-bottom-color: var(--line); }
.lib-lines--related .lib-line:hover { background: var(--sand); }
.lib-line__text--related { font-size: 20px; text-overflow: ellipsis; }

@media (max-width: 600px) {
  .lib-related { gap: 10px; }
  .lib-related--second { padding-top: 20px; }
  .lib-related__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 8px; }
  .lib-related__h, .lib-related--second .lib-related__h { font-size: 26px; }
  .lib-related__info-button { order: 0; width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 50%; }
  .lib-related__i { width: auto; height: auto; border: 0; font-size: 18px; font-weight: 400; }
  .lib-related__info-label { display: none; }
  .lib-related__info-sr { display: inline; }
  .lib-related__note { grid-column: 1 / -1; margin-top: -4px; font-size: 13px; }
  .lib-related__info { padding: 10px 12px; font-size: 13px; line-height: 1.5; }
  .lib-related__status { font-size: 20px; }
  .lib-related__placeholder { padding: 16px; border-radius: 16px; }
  .lib-related__placeholder span:nth-child(1) { width: 170px; }
  .lib-related__placeholder span:nth-child(2) { display: none; }
  .lib-related__tier { font-size: 11px; gap: 10px; }
  .lib-related__book { gap: 6px; padding: 14px 14px 6px; border-radius: 16px; }
  .lib-related__title { font-size: 20px; }
  .lib-line__text--related { font-size: 18px; }
}

/* The Uploaded tab's two ways to add a text: a file, or an article from
   the language's Wikipedia (WikipediaController); and the link under search results. */
.lib__add-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.lib__add-cards > *, .lib__upload-text, .lib__wiki-head { min-width: 0; }
.lib__wiki { flex-direction: column; flex-wrap: nowrap; align-items: stretch; } /* one line: a wrapping column would size its items to their longest line */
.lib__wiki-head { display: flex; align-items: flex-start; gap: 14px; }
.lib__wiki-mark {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: var(--radius-sm); background: var(--sand); font-family: var(--font-serif); font-size: 22px; color: var(--ink);
}
.lib__wiki-mark--sm { width: 22px; height: 22px; border-radius: 50%; font-size: 13px; border: 1px solid var(--line-strong); background: none; }
.lib__wiki-search { display: flex; align-items: center; gap: 8px; }
.lib__wiki-input {
  flex: 1; min-width: 0; height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
  background: var(--field); font: inherit; font-size: 15px; color: var(--ink);
}
.lib__wiki-input:dir(rtl), .lib__wiki-input:placeholder-shown { font-family: var(--font-arabic); font-size: 18px; }
/* A right-to-left language's placeholder sits on the right (a left-to-right one's input says dir="ltr"). */
.lib__wiki-input:not([dir="ltr"]):placeholder-shown { direction: rtl; text-align: right; /* physical: text in the language taught keeps its own side */ }
.lib__wiki-input:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.lib-search__wikipedia { margin: 8px 0 0; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; font-size: 14px; }
.lib-search__wikipedia a { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.lib-search__wikipedia .ar { font-size: 18px; }

/* ------------------------------------------------------------------
   Library redesign (design "Library Redesign"): For you, Browse, Shelves.
   ------------------------------------------------------------------ */

.library { display: flex; flex-direction: column; gap: 28px; }
.library__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.library__title { margin: 0; }
.library__tabs { display: inline-flex; padding: 4px; gap: 2px; background: var(--sand); border-radius: var(--radius-pill); }
.library__tab {
  padding: 9px 22px; border-radius: var(--radius-pill);
  color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none;
}
.library__tab:hover { background: var(--sand-hover); color: var(--ink); text-decoration: none; }
.library__tab[aria-current="page"] { background: var(--ink); color: var(--paper); }
.library__tab--locked { color: var(--text-muted); }
.library__section { display: flex; flex-direction: column; gap: 14px; }
.library__row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.library__h2 { margin: 0; font-family: var(--font-serif); font-size: 28px; font-weight: 400; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.library__level-chip { padding: 2px 9px; border-radius: var(--radius-pill); background: var(--ink); color: var(--paper); font-family: var(--font-sans); font-size: 12px; font-weight: 700; }
.library__see-all { font-size: 13px; font-weight: 600; color: var(--clay); white-space: nowrap; }
.library__more-places { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.library__place { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; color: var(--ink); text-decoration: none; }

/* Rows of cards: a grid on a computer, scrolling sideways on a phone. */
.book-row, .book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.book-row--continue { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* The book card. */
.book-card {
  position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md);
}
.book-card[draggable="true"] { cursor: grab; }
.book-card.is-dragging { opacity: .55; border-style: dashed; border-color: var(--line-dashed, var(--line-strong)); }
.book-card.is-menu-open { z-index: 5; }
.book-card__top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.book-card__tag { padding: 3px 7px; border-radius: var(--radius-sm); background: var(--sand); color: var(--ink); font-size: 11px; font-weight: 700; white-space: nowrap; }
.book-card__only { font-size: 11px; color: var(--text-muted); }
.book-card__tools { margin-inline-start: auto; display: flex; align-items: center; gap: 2px; }
.book-card__saved { display: inline-flex; color: var(--green); }
.book-card__saved .icon { width: 14px; height: 14px; fill: currentColor; }
.book-card__more {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: none; color: var(--ink);
}
.book-card__more:hover, .book-card__more[aria-expanded="true"] { background: var(--sand); }
.book-card__menu {
  position: absolute; inset-inline-end: 8px; top: 44px; z-index: 10; min-width: 210px;
  display: flex; flex-direction: column; padding: 6px; background: var(--card);
  border: 1px solid var(--line-strong); border-radius: var(--radius-input); box-shadow: 0 12px 32px rgb(0 0 0 / .16);
}
.book-card__menu[hidden] { display: none; }
.book-card__form { display: contents; }
.book-card__item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--ink); font: inherit; font-size: 14px; text-align: start; text-decoration: none;
}
.book-card__item:hover, .book-card__item:focus-visible { background: var(--sand); color: var(--ink); text-decoration: none; }
.book-card__item .icon { width: 16px; height: 16px; flex: none; }
.book-card__item--danger { color: var(--clay); }
.book-card__native { margin: 0; font-size: 22px; line-height: 1.5; color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.book-card__title {
  margin: 0; font-family: var(--font-serif); font-size: 17px; font-weight: 400; line-height: 1.25; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-card__title--none { font-family: var(--font-sans); font-size: 13px; font-style: italic; color: var(--text-muted); }
.book-card__meta { margin: 0; font-size: 12px; color: var(--text-muted); }
.book-card__shelves { display: flex; align-items: flex-start; gap: 5px; margin: 4px 0 0; font-size: 11px; font-weight: 700; color: var(--green); }
.book-card__shelves .icon { width: 13px; height: 13px; flex: none; margin-top: 1px; }
.book-card__progress { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin-top: 8px; font-size: 12px; }
.book-card__bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.book-card__bar span { display: block; height: 100%; background: var(--green); border-radius: 2px; }
.book-card__reason { margin: 6px 0 0; font-size: 11px; color: var(--text-muted); }
.book-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 14px; flex-wrap: wrap; }
.book-card__coverage { font-size: 12px; font-weight: 700; }
.book-card__coverage--high { color: var(--green); }
.book-card__coverage--mid { color: var(--gold-deep); }
.book-card__coverage--low { color: var(--clay); }
.book-card__status { font-size: 12px; color: var(--text-muted); }
.book-card__status--failed { color: var(--clay); }
.book-card__signup { font-size: 12px; font-weight: 600; }
.book-card .btn--sm { border-radius: var(--radius-pill); }

/* Shelf tiles. */
.shelf-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.shelf-tile {
  display: flex; flex-direction: column; gap: 4px; padding: 12px; min-height: 150px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md);
  color: var(--ink); text-decoration: none; font: inherit; text-align: start;
}
.shelf-tile:hover { border-color: var(--line-strong); color: var(--ink); text-decoration: none; }
.shelf-tile__stack { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; min-height: 76px; }
.shelf-tile__spine {
  display: block; padding: 2px 8px; border-radius: 4px; font-size: 13px; line-height: 1.5;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: end;
}
.shelf-tile__spine--0 { background: var(--sand); }
.shelf-tile__spine--1 { background: var(--clay-soft); }
.shelf-tile__spine--2 { background: var(--green-soft); }
.shelf-tile__hint { font-size: 12px; color: var(--text-muted); }
.shelf-tile__name { font-size: 14px; }
.shelf-tile__count { font-size: 12px; color: var(--text-muted); }
.shelf-tile--new { align-items: center; justify-content: center; border-style: dashed; background: none; cursor: pointer; }
.shelf-tile--new .icon { width: 22px; height: 22px; }
.shelf-tiles__invite p { margin: 0; font-size: 13px; color: var(--text-muted); }

/* Find something to read. */
.library-find { display: flex; flex-direction: column; gap: 10px; padding: 22px; }
.library-find__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.library-find__label { margin: 6px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.library-find__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.library-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill); background: var(--card); color: var(--ink); font-size: 13px; text-decoration: none;
}
.library-chip:hover { background: var(--sand); color: var(--ink); text-decoration: none; }
.library-chip.is-own { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.library-chip__count { color: var(--text-muted); font-size: 12px; }
.library-chip.is-own .library-chip__count { color: var(--text-on-dark-muted); }
.library-chip--strong { font-weight: 700; }

/* Adding: an upload and Wikipedia, side by side. */
.library-add { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.library-add__item {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-md);
}
.library-add__icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--sand); flex: none; font-family: var(--font-serif); font-weight: 700; }
.library-add__text { display: flex; flex-direction: column; flex: 1; min-width: 160px; font-size: 13px; }
.library-add__search { display: flex; gap: 6px; flex: 1 1 220px; }
.library-add__search .input { flex: 1; min-width: 0; }

/* Messages with Undo. */
.library-toast { position: fixed; inset-inline: 0; bottom: 24px; z-index: 60; display: flex; justify-content: center; pointer-events: none; }
.library-toast__message {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--paper); border-radius: var(--radius-pill); box-shadow: 0 10px 28px rgb(0 0 0 / .25);
  font-size: 14px; pointer-events: auto;
}
.library-toast__form { display: contents; }
.library-toast__undo { border: 0; background: none; color: var(--peach, var(--paper)); font: inherit; font-weight: 700; text-decoration: underline; }
.library-toast__close { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--paper); }
.library-toast__close .icon { width: 14px; height: 14px; }

/* Add to shelf…: a box on a computer, a sheet from the bottom on a phone. */
.shelf-picker {
  width: min(380px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-card);
  background: var(--card); color: var(--ink); box-shadow: 0 20px 50px rgb(0 0 0 / .25);
}
.shelf-picker::backdrop { background: rgb(20 24 22 / .35); }
.shelf-picker turbo-frame { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.shelf-picker__loading { margin: 0; }
.shelf-picker__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.shelf-picker__title { margin: 0; font-size: 16px; }
.shelf-picker__close { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--ink); flex: none; }
.shelf-picker__close:hover { background: var(--sand); }
.shelf-picker__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }
.shelf-picker__form { display: contents; }
.shelf-picker__row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--ink); font: inherit; font-size: 15px; text-align: start;
}
.shelf-picker__row:hover { background: var(--sand); }
.shelf-picker__box { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1.5px solid var(--line-strong); border-radius: 5px; font-size: 13px; flex: none; }
.shelf-picker__row[aria-checked="true"] .shelf-picker__box { background: var(--green); border-color: var(--green); color: var(--paper); }
.shelf-picker__new { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.shelf-picker__new-label { font-size: 13px; font-weight: 700; }
.shelf-picker__new-row { display: flex; gap: 8px; }
.shelf-picker__new-row .input { flex: 1; min-width: 0; }
.shelf-picker__foot { display: flex; justify-content: flex-end; }

/* Browse: filters beside the books, and the shelves to drop on. */
.browse { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px 28px; align-items: start; }
.browse--shelves { grid-template-columns: 220px minmax(0, 1fr) 200px; }
.browse__form { display: contents; }
.browse__bar { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.browse__search {
  flex: 1 1 320px; display: flex; align-items: center; gap: 10px; min-height: 46px; padding-inline: 16px;
  background: var(--field); border: 1px solid var(--line-strong); border-radius: var(--radius-pill); color: var(--text-muted);
}
.browse__search:focus-within { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), 0 0 0 4px var(--green-soft); }
.browse__search-input { flex: 1; min-width: 0; height: 44px; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; color: var(--ink); }
.browse__search-input::placeholder { color: var(--text-muted); opacity: 1; }
.browse__sort { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px 0 14px; min-height: 42px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--card); font-size: 13px; }
.browse__sort-label { color: var(--text-muted); }
.browse__sort-select { border: 0; background: transparent; font: inherit; font-weight: 700; color: var(--ink); padding: 8px 4px; }
.browse__filters-open { display: none; }
.browse__badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--ink); color: var(--paper); font-size: 11px; }
.browse__filters { grid-column: 1; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding-inline-end: 4px; }
.browse__sheet-head, .browse__sheet-foot { display: none; }
.browse__filters-title { margin: 0; font-size: 18px; }
.browse__group { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 4px; }
.browse__legend { padding: 0; margin-bottom: 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.browse__levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.browse__level {
  display: flex; flex-direction: column; align-items: center; padding: 6px 4px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--card); cursor: pointer; font-size: 13px;
}
.browse__level.is-own { border-color: var(--green); }
.browse__level:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.browse__level:has(input:checked) .browse__count { color: var(--text-on-dark-muted); }
.browse__level:has(input:focus-visible) { outline: 3px solid var(--green); outline-offset: 2px; }
.browse__level-name { font-weight: 700; }
.browse__note { margin: 4px 0 0; font-size: 12px; color: var(--green); font-weight: 600; }
.browse__option { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; cursor: pointer; }
.browse__option input { accent-color: var(--ink); width: 16px; height: 16px; margin: 0; }
.browse__option.is-empty { color: var(--text-muted); }
.browse__count { margin-inline-start: auto; font-size: 12px; color: var(--text-muted); }
.browse__main { grid-column: 2; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.browse__chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.browse__chip { display: inline-flex; gap: 6px; padding: 5px 12px; border-radius: var(--radius-pill); background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 600; text-decoration: none; }
.browse__chip:hover { color: var(--paper); background: var(--ink-raised, var(--ink)); text-decoration: none; }
.browse__clear { font-size: 13px; text-decoration: underline; }
.browse__summary { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.browse__total { margin: 0; font-family: var(--font-serif); font-size: 26px; color: var(--ink); }
.browse__hidden-link { font-size: 13px; color: var(--text-muted); text-decoration: underline; }
.browse__more { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 8px; }
.browse__shown { margin: 0; font-size: 13px; color: var(--text-muted); }
.browse-empty { padding: 28px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); }
.browse-empty__title { margin: 0 0 8px; font-family: var(--font-serif); font-size: 22px; }
.browse-empty__ways { margin: 8px 0 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; }
.browse .lib-search { grid-column: auto; }

/* The shelves to drop a card on. */
.drop-shelves { grid-column: 3; position: sticky; top: 16px; display: flex; flex-direction: column; gap: 8px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); }
.drop-shelves__title { margin: 0; font-size: 15px; }
.drop-shelves__hint { margin: 0; font-size: 12px; color: var(--text-muted); }
.drop-shelves__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.drop-shelf {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 10px; min-height: 44px;
  border: 1px solid var(--line); border-radius: var(--radius-input); font-size: 13px; background: var(--paper);
}
.drop-shelf__icon { display: inline-flex; color: var(--text-muted); }
.drop-shelf__icon .icon { width: 15px; height: 15px; }
.drop-shelf__name { flex: 1; min-width: 0; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-shelf__count { font-size: 12px; color: var(--text-muted); }
.drop-shelf--new { border-style: dashed; }
.is-dragging-book .drop-shelf { border-style: dashed; border-color: var(--line-strong); }
.drop-shelf.is-over { border: 2px dashed var(--green); background: var(--green-soft); }
.drop-shelf.is-over::after {
  content: attr(data-drop-label); position: absolute; inset: 0; display: grid; place-items: center;
  border-radius: inherit; background: var(--green-soft); color: var(--green-deep, var(--green)); font-weight: 700;
}

/* A shelf's page. */
.shelf-page__crumbs { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); }
.shelf-page__crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.shelf-page__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.shelf-page__head p { margin: 4px 0 0; }
.shelf-page__title { margin: 0; }
.shelf-page__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.shelf-page__actions form { display: inline; }
.shelf-page__rename { position: relative; }
.shelf-page__rename summary { list-style: none; }
.shelf-page__rename summary::-webkit-details-marker { display: none; }
.shelf-page__rename-form {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 5; display: flex; gap: 6px; padding: 10px; width: 300px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-input); box-shadow: 0 12px 32px rgb(0 0 0 / .14);
}
.shelf-page__rename-form .input { flex: 1; min-width: 0; }
.shelf-page__empty { padding: 28px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.shelf-page__empty p { margin: 0; }
.shelf-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.shelf-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 60px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-input);
}
.shelf-row.is-dragging { opacity: .5; border-style: dashed; }
.shelf-row.is-lifted { border: 2px solid var(--green); box-shadow: 0 10px 24px rgb(0 0 0 / .12); }
.shelf-row__handle { display: inline-grid; place-items: center; width: 32px; height: 40px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-muted); cursor: grab; flex: none; }
.shelf-row__handle:hover { background: var(--sand); color: var(--ink); }
.shelf-row__number { width: 22px; text-align: center; font-size: 13px; color: var(--text-muted); flex: none; }
.shelf-row__titles { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 12px; overflow: hidden; }
.shelf-row__native { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; }
.shelf-row__title { font-family: var(--font-serif); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shelf-row__level { padding: 2px 7px; border-radius: var(--radius-sm); background: var(--sand); font-size: 11px; font-weight: 700; flex: none; }
.shelf-row__coverage { flex: none; min-width: 90px; }
.shelf-row__go { flex: none; border-radius: var(--radius-pill); }
.shelf-row__moves { display: flex; gap: 2px; opacity: 0; flex: none; }
.shelf-row:hover .shelf-row__moves, .shelf-row:focus-within .shelf-row__moves { opacity: 1; }
.shelf-row__move, .shelf-row__remove, .shelf-row__more {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: none; color: var(--text-muted); font-size: 15px;
}
.shelf-row__move:hover, .shelf-row__remove:hover, .shelf-row__more:hover { background: var(--sand); color: var(--ink); }
.shelf-row__remove .icon { width: 14px; height: 14px; }
.shelf-row__remove-form { display: contents; }
.shelf-row__menu-wrap { position: relative; display: none; }
.shelf-row__menu-wrap .book-card__menu { top: 36px; inset-inline-end: 0; }

@media (max-width: 1100px) {
  .browse--shelves { grid-template-columns: 220px minmax(0, 1fr); }
  .drop-shelves { display: none; }
}

@media (max-width: 760px) {
  .library { gap: 22px; }
  .library__head { flex-direction: column; align-items: stretch; }
  .library__tabs { justify-content: space-between; }
  .library__tab { flex: 1; text-align: center; padding-inline: 10px; }
  .library__h2 { font-size: 22px; }
  .book-row, .book-row--continue {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; padding-bottom: 6px;
  }
  .book-row .book-card { flex: 0 0 min(76vw, 260px); scroll-snap-align: start; }
  .book-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .book-card { padding: 12px; }
  .book-card__native { font-size: 19px; }
  .shelf-tiles { display: flex; overflow-x: auto; padding-bottom: 6px; }
  .shelf-tile { flex: 0 0 150px; }

  .browse, .browse--shelves { grid-template-columns: minmax(0, 1fr); }
  .browse__main { grid-column: 1; }
  .browse__filters-open { display: inline-flex; gap: 6px; align-items: center; }
  .browse__search { flex-basis: 100%; }
  .browse__filters {
    position: fixed; inset: auto 0 0 0; top: auto; z-index: 70; max-height: 85vh; padding: 18px 18px 0;
    background: var(--card); border-radius: var(--radius-card) var(--radius-card) 0 0; box-shadow: 0 -12px 40px rgb(0 0 0 / .25);
    transform: translateY(105%); transition: transform .2s ease; visibility: hidden;
  }
  .browse__filters.is-open { transform: none; visibility: visible; }
  .browse__sheet-head { display: flex; justify-content: space-between; align-items: center; }
  .browse__sheet-close { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--sand); color: var(--ink); }
  .browse__sheet-foot {
    display: flex; gap: 10px; position: sticky; bottom: 0; padding: 12px 0 18px; background: var(--card); border-top: 1px solid var(--line);
  }
  .browse__show { flex: 1; }
  .browse__option { min-height: 44px; }
  body.has-sheet { overflow: hidden; }

  .shelf-picker { margin: auto 0 0; width: 100%; max-width: none; border-radius: var(--radius-card) var(--radius-card) 0 0; }
  .shelf-picker__row { min-height: 52px; }

  .shelf-row { flex-wrap: wrap; gap: 8px; padding: 10px; }
  .shelf-row__titles { flex-basis: calc(100% - 120px); flex-direction: column; gap: 0; }
  .shelf-row__native { max-width: 100%; }
  .shelf-row__moves, .shelf-row__remove-form, .shelf-row__remove { display: none; }
  .shelf-row__menu-wrap { display: block; }
  .shelf-row__coverage { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .browse__filters { transition: none; }
}
.book-card__top { flex-wrap: wrap; min-width: 0; }
.book-card__tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.book-card__tools { order: 9; }
@media (max-width: 760px) {
  .book-card__top .source-tag { display: none; }
}
/* Browse's search: the hint under the box while it's empty and focused; × once something is typed. */
.browse__hint { flex-basis: 100%; order: 9; }
.browse__bar:focus-within:has(.browse__search-input:placeholder-shown) .browse__hint { display: block; }
.browse__search:has(.browse__search-input:placeholder-shown) .lib__search-clear { display: none; }
.browse__search-input::-webkit-search-cancel-button { appearance: none; }
.browse__search-input:dir(rtl) { font-family: var(--font-arabic); font-size: 20px; }
.book-card__next { grid-column: 1 / -1; font-size: 11px; font-weight: 700; }
.drop-shelf--new { padding: 0; }
.drop-shelf__new {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 10px; border: 0; border-radius: inherit;
  background: none; color: var(--ink); font: inherit; text-align: start; cursor: pointer;
}
.drop-shelf__new:hover { background: var(--sand); }
