:root {
  color-scheme: light;
  --canvas: #f2f2f2;
  --surface: #fff;
  --ink: #242424;
  --muted: #565b60;
  --line: #d6d8da;
  --control-border: #878e95;
  --masthead: #252525;
  --link: #18547d;
  --selection: #e6edf2;
  --radius: 3px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden], .book-year:empty, .book-size:empty { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--canvas); line-height: 1.5; }
button, input, select { color: inherit; font: inherit; }
button, select { cursor: pointer; }
a, .read-link { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
button:disabled, select:disabled { cursor: default; opacity: .55; }
.wrap { width: min(1160px, 100% - 64px); margin-inline: auto; }

.visually-hidden, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus { position: absolute; z-index: 1; padding: .5rem 1rem; background: var(--surface); }

.masthead { background: var(--masthead); color: #fff; }
.masthead-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 55px; }
.masthead a { color: inherit; text-decoration: none; }
.masthead a:hover { text-decoration: underline; }
.masthead a:focus-visible { outline-color: #fff; }
.brand { display: inline-flex; align-items: center; gap: .7rem; font-size: 1.05rem; font-weight: 700; }
.brand-icon {
  width: 18px;
  height: 19px;
  border: 1.5px solid currentColor;
  border-left-width: 5px;
  border-radius: 2px 3px 3px 2px;
}
.masthead nav { font-size: .875rem; }

.intro { padding-block: 2rem 2.25rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.intro h1 { margin: 0; font-size: clamp(1.8rem, 4.5vw, 2.6rem); font-weight: 600; line-height: 1.15; }
.intro p { margin: .6rem 0 1.4rem; color: var(--muted); }
.search-form { display: flex; align-items: stretch; gap: .5rem; max-width: 46rem; }
.search-field {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: .8rem;
  padding-inline: .85rem;
  border: 1px solid var(--control-border);
  border-radius: var(--radius);
}
.search-field:focus-within { outline: 2px solid var(--link); outline-offset: 2px; }
.search-field input { width: 100%; min-width: 0; padding: .58rem 0; border: 0; background: transparent; outline: none; }
.search-field input::placeholder { color: var(--muted); opacity: 1; }
.search-icon {
  position: relative;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  margin-right: 3px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  color: var(--muted);
}
.search-icon::after {
  position: absolute;
  right: -5px;
  bottom: -2px;
  width: 6px;
  height: 1.5px;
  background: currentColor;
  transform: rotate(45deg);
  content: "";
}
.primary {
  display: inline-block;
  padding: .55rem 1.15rem;
  border: 1px solid var(--link);
  border-radius: var(--radius);
  background: var(--link);
  color: #fff;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.primary:hover { background: #123f5e; }

.collection {
  display: grid;
  grid-template-columns: minmax(170px, 216px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(1rem, 3vw, 2rem);
  padding-block: 1.6rem 3.5rem;
}
.filters {
  min-width: 0;
  padding: .95rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.filters h2 { margin: 0 0 .75rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); font-size: 1rem; }
.filters fieldset { min-width: 0; margin: 0 0 .9rem; padding: 0; border: 0; }
.filters legend, .field label { display: block; margin-bottom: .35rem; padding: 0; font-size: .875rem; font-weight: 700; }
.language-filter {
  display: flex;
  justify-content: space-between;
  gap: .4rem;
  width: 100%;
  padding: .32rem .48rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  font-size: .875rem;
  text-align: left;
}
.language-filter[aria-pressed="true"] { background: var(--selection); color: var(--link); font-weight: 700; }
.language-filter:hover { border-color: var(--control-border); }
.language-filter span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.select-field { position: relative; }
.select-field::after {
  position: absolute;
  top: calc(50% - 5px);
  right: .8rem;
  width: 6px;
  height: 6px;
  border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  pointer-events: none;
  content: "";
}
select {
  appearance: none;
  width: 100%;
  min-height: 38px;
  padding: .35rem 1.9rem .35rem .6rem;
  border: 1px solid var(--control-border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: .875rem;
}
.clear-button {
  margin-top: .8rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font-size: .875rem;
  text-align: left;
  text-decoration: underline;
}

.results-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .6rem 1rem; margin-bottom: .8rem; }
.results-heading h2 { margin: 0; font-size: 1.45rem; line-height: 1.22; scroll-margin-top: 1rem; }
.results-heading p { margin: .2rem 0 0; color: var(--muted); font-size: .875rem; }
.view-tools, .view-toggle { display: flex; align-items: center; }
.view-tools { gap: .55rem; }
.view-toggle { border: 1px solid var(--control-border); border-radius: var(--radius); background: var(--surface); }
.view-toggle button { display: grid; place-items: center; width: 37px; height: 36px; border: 0; background: transparent; }
.view-toggle button + button { border-left: 1px solid var(--control-border); }
.view-toggle button:hover, .view-toggle button[aria-pressed="true"] { background: var(--selection); color: var(--link); }
.grid-icon {
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, transparent 44%, currentColor 44% 56%, transparent 56%),
    linear-gradient(transparent 44%, currentColor 44% 56%, transparent 56%);
}
.list-icon { width: 15px; height: 11px; border-block: 1.5px solid currentColor; background: linear-gradient(transparent 40%, currentColor 40% 60%, transparent 60%); }

.books { padding: 0; margin: 0; list-style: none; }
.books:empty { display: none; }
.books[data-view="list"] { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.books[data-view="list"] .book + .book { border-top: 1px solid var(--line); }
.book {
  display: grid;
  grid-template-columns: 23px minmax(0, 1fr) minmax(76px, .25fr) 76px;
  align-items: start;
  gap: .25rem 1rem;
  min-width: 0;
  padding: .85rem 1rem;
}
.book-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 23px;
  margin-top: .05rem;
  border: 1px solid #87939b;
  border-radius: 2px;
  background: #f4f6f7;
}
.book-icon::after {
  position: absolute;
  inset: 6px 3px auto;
  height: 7px;
  border-block: 1px solid #87939b;
  content: "";
}
.book-title {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
}
.book-title:hover { text-decoration: underline; }
.book-credit { margin: .22rem 0 0; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.book-meta, .book-actions { display: grid; gap: .1rem .65rem; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.book-actions { justify-items: end; }
.read-link { font-weight: 600; white-space: nowrap; }

.books[data-view="grid"] { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 225px), 1fr)); gap: .75rem; }
.books[data-view="grid"] .book {
  grid-template-columns: 23px minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  align-content: start;
  gap: .55rem .65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.books[data-view="grid"] .book-meta,
.books[data-view="grid"] .book-actions { grid-column: 2; grid-auto-flow: column; justify-content: start; align-items: baseline; }

.empty, dialog { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty { padding: 1.25rem; color: var(--muted); }
#pagination { display: flex; justify-content: center; align-items: center; gap: .65rem; margin-top: 1.2rem; font-size: .875rem; }
#pagination button, .dialog-close button { padding: .35rem .7rem; border: 1px solid var(--control-border); border-radius: var(--radius); background: var(--surface); color: var(--link); }
#pagination button:not(:disabled):hover, .dialog-close button:hover { background: var(--selection); }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .35rem 1rem; min-height: 64px; padding-block: .7rem; color: var(--muted); font-size: .875rem; }
.footer-inner span { font-weight: 700; }
dialog { width: min(500px, 100% - 32px); padding: 1.5rem; color: var(--ink); }
dialog::backdrop { background: #0009; }
dialog h2 { margin: 0; font-size: 1.5rem; line-height: 1.25; overflow-wrap: anywhere; }
dialog p { margin: .6rem 0; }
#book-language { margin: 0 2rem .45rem 0; color: var(--muted); font-size: .875rem; }
#book-filename { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
dialog .primary { margin-top: .3rem; }
.dialog-close { position: absolute; top: .65rem; right: .65rem; }
.dialog-close button { padding: 0 .5rem; font-size: 1.25rem; }

@media (max-width: 760px) {
  .wrap { width: calc(100% - 32px); }
  .collection { grid-template-columns: 1fr; }
  .filters { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: .65rem 1rem; }
  .filters h2 { grid-column: 1 / -1; margin: 0; }
  .filters fieldset { margin: 0; }
  #languages { display: flex; flex-wrap: wrap; gap: .25rem; }
  .language-filter { width: auto; border-color: var(--line); }
  .clear-button { margin: 0; }
}

@media (max-width: 480px) {
  .intro { padding-block: 1.45rem; }
  .search-field { padding-inline: .55rem; }
  .search-icon { display: none; }
  .primary { padding-inline: .7rem; }
  .filters { grid-template-columns: 1fr; }
  .field { max-width: 11rem; }
  .book { grid-template-columns: 18px minmax(0, 1fr); column-gap: .55rem; padding-inline: .75rem; }
  .book-meta, .book-actions { grid-column: 2; grid-auto-flow: column; justify-content: start; align-items: baseline; }
}
