@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --paper: #f8ebdd;
  --quiet: #c7b9cb;
  --gold: #efc98e;
  --line: #705667;
  --night: #14101c;
  --panel: #251a2b;
  --heading: Cinzel, Georgia, serif;
  --body: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 22px; }
body { margin: 0; background: var(--night); color: var(--paper); font: 16px/1.55 var(--body); }
a { color: inherit; }
button, input { font: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

.library-masthead { border-bottom: 1px solid #5b485d; background: #191321; }
.library-masthead nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 2 * clamp(20px, 5vw, 72px), 1360px);
  min-height: 66px;
  margin: auto;
}
.library-brand img { display: block; width: 128px; height: auto; }
.library-nav { display: flex; align-items: center; gap: clamp(14px, 3vw, 28px); }
.library-nav a { display: grid; min-height: 44px; align-items: center; color: var(--quiet); font-weight: 650; text-decoration: none; }
.library-nav a:is(:hover, [aria-current]) { color: var(--gold); }

.library-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr);
  gap: clamp(25px, 5vw, 76px);
  align-items: center;
  padding: clamp(38px, 6vw, 96px) max(clamp(20px, 5vw, 72px), calc((100% - 1360px) / 2));
  min-height: 430px;
  overflow: hidden;
  border-bottom: 1px solid #70505b;
  background:
    radial-gradient(ellipse at 76% 38%, #75524574, transparent 53%),
    linear-gradient(124deg, #211727 20%, #2d2033 63%, #211725);
}
.library-hero h1, .book-copy h1 {
  margin: 0;
  max-width: 16ch;
  font: 650 clamp(40px, 5.05vw, 76px)/1.06 var(--heading);
  letter-spacing: -.035em;
  text-wrap: balance;
}
.library-hero p { max-width: 39ch; margin: 18px 0 25px; color: #e2d2de; font-size: clamp(15px, 1.6vw, 19px); }
.library-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 17px;
  border: 1px solid #ffdb9f;
  border-radius: 5px;
  background: var(--gold);
  color: #2b1823;
  font-weight: 750;
  text-decoration: none;
}
.library-button:hover { background: #ffe1ac; }

.library-featured {
  isolation: isolate;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: clamp(0px, 1vw, 12px);
  max-width: 640px;
  padding: 20px 7% 14px;
}
.library-featured::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0 1.5% 10px;
  border-radius: 50%;
  border: 1px solid #e6b58236;
  box-shadow: 0 0 0 13px #e6b5820e, 0 0 0 30px #e6b58212;
  transform: rotate(-9deg);
}
.library-featured a { display: block; transition: translate 160ms ease; }
.library-featured a:hover { translate: 0 -6px; }
.library-featured a:first-child { transform: rotate(-11deg) translate(5%, 5%); }
.library-featured a:nth-child(2) { z-index: 1; transform: translateY(-9%) scale(1.16); }
.library-featured a:last-child { transform: rotate(10deg) translate(-6%, 5%); }
.library-featured .book-cover { width: 100%; box-shadow: 0 12px 22px #0b070cb3, 0 0 0 1px #dbae7b48; }

.library-content {
  width: min(100% - 2 * clamp(20px, 5vw, 72px), 1360px);
  margin-inline: auto;
  padding-block: clamp(25px, 5vw, 58px) clamp(42px, 6vw, 90px);
}
.library-controls {
  display: grid;
  grid-template-columns: minmax(175px, 1fr) 2fr;
  align-items: end;
  gap: 10px clamp(18px, 4vw, 48px);
  margin-bottom: 30px;
}
.library-search label, .library-filters legend { display: block; margin-bottom: 7px; color: #f0dfef; font-size: 13px; font-weight: 750; }
.library-search input {
  width: 100%;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--paper);
}
.library-search input::placeholder { color: var(--quiet); }
.library-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.library-filters button {
  min-height: 44px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--quiet);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.library-filters button:hover { color: var(--paper); border-color: var(--gold); }
.library-filters button[aria-pressed="true"] { border-color: #ae7d6a; background: #472c39; color: #ffe6c3; }
.library-count { margin: 0; color: var(--quiet); font-size: 13px; }
.library-empty { color: var(--quiet); }

.library-shelf + .library-shelf { margin-top: 35px; }
.library-shelf h2, .book-places h2 { margin: 0 0 12px; font: 650 clamp(22px, 3.4vw, 35px)/1.2 var(--heading); color: #f3e0c7; }
.library-shelf ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
  border: 1px solid #644e58;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 0%, #64485040, transparent 72%), #231a28;
}
.library-book { min-width: 0; border-bottom: 1px solid #4d374d; }
.library-book a { display: block; height: 100%; padding-bottom: 16px; text-decoration: none; }
.library-book a:hover { background: #533a4c55; }
.library-book a:focus-visible { outline-offset: -3px; }
.book-stand {
  --stand-height: clamp(168px, 19vw, 242px);
  --cover-height: calc(var(--stand-height) - 31px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 23px 16px 0;
  height: var(--stand-height);
  margin-bottom: 13px;
  border-bottom: 7px solid #7e5150;
  box-shadow: 0 5px 8px #100b14aa, inset 0 -10px 11px #160f19ad;
}
.book-cover {
  --binding-top: #574061;
  --binding-bottom: #281a34;
  position: relative;
  display: grid;
  overflow: hidden;
  width: 100%;
  height: auto;
  aspect-ratio: var(--cover-ratio, .6667);
  border-radius: 2px 4px 4px 2px;
  background: linear-gradient(135deg, var(--binding-top), var(--binding-bottom) 70%);
  box-shadow: 3px 0 0 #beb2aa, 5px 2px 0 #574d54, 7px 6px 13px #100910be;
}
.book-cover[data-theme="1"], .book-cover[data-theme="6"] { --binding-top: #67463d; --binding-bottom: #3c242b; }
.book-cover[data-theme="2"], .book-cover[data-theme="4"] { --binding-top: #3d5552; --binding-bottom: #233037; }
.book-cover[data-theme="3"], .book-cover[data-theme="5"] { --binding-top: #64414b; --binding-bottom: #351e31; }
.book-stand .book-cover { width: min(100%, calc(var(--cover-height) * var(--cover-ratio, .6667))); max-height: var(--cover-height); }
.book-cover img {
  position: absolute;
  display: block;
  left: var(--image-left, 0);
  top: var(--image-top, 0);
  width: var(--image-width, 100%);
  height: var(--image-height, 100%);
  max-width: none;
  object-fit: cover;
}
.book-cover-fallback {
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  place-items: center;
  gap: 7px;
  min-width: 0;
  padding: 8%;
  margin: 8%;
  border: 1px solid #ddb9946b;
  text-align: center;
  overflow: hidden;
  color: #f1d5a9;
}
.book-cover-fallback span { font: 600 clamp(7px, .8vw, 11px)/1.15 var(--body); overflow-wrap: anywhere; }
.book-cover-fallback strong { font: 650 clamp(8px, 1.1vw, 16px)/1.15 var(--heading); overflow-wrap: anywhere; }
.book-tile-title, .library-book small { display: block; padding-inline: 11px; }
.book-tile-title { color: #fff1df; font-size: 14px; font-weight: 700; line-height: 1.3; }
.library-book small { margin-top: 4px; color: var(--quiet); line-height: 1.25; }

.library-detail { max-width: 1090px; }
.library-back { display: inline-flex; align-items: center; min-height: 44px; gap: 7px; margin-bottom: 12px; color: var(--gold); }
.book-detail { display: grid; grid-template-columns: minmax(180px, 31%) minmax(0, 1fr); gap: clamp(22px, 6vw, 80px); align-items: start; }
.book-display {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: clamp(17px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: radial-gradient(ellipse at 45% 25%, #5b4056, #2b202f 75%);
}
.book-display .book-cover { max-width: 242px; }
.cover-caption { margin: 0; color: var(--quiet); font-size: 13px; text-align: center; }
.book-actions > a:not(.library-button) { color: var(--quiet); font-size: 13px; text-underline-offset: 3px; }
.book-actions > a:hover { color: var(--gold); }
.book-actions > .library-button:hover { color: #2b1823; }
.book-category { margin: 0 0 11px; color: var(--gold); font-size: 13px; font-weight: 750; }
.book-copy h1 { max-width: 26ch; font-size: clamp(28px, 4.2vw, 58px); overflow-wrap: anywhere; }
.book-description { max-width: 58ch; margin: 16px 0 21px; color: #e5d6e6; font-size: 17px; }
.book-edition { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin: 20px 0; padding-block: 16px; border-block: 1px solid #4c364c; }
.book-edition dt { color: var(--quiet); font-size: 12px; }
.book-edition dd { margin: 2px 0 0; color: var(--paper); font-weight: 600; line-height: 1.34; overflow-wrap: anywhere; }
.book-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 17px; }
.book-continuity { color: var(--quiet); font-size: 13px; }
.book-places { margin-top: clamp(29px, 5vw, 62px); }
.book-places ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); gap: 7px; margin: 0; padding: 0; list-style: none; }
.book-places li { padding: 12px 14px; border: 1px solid #584257; border-radius: 5px; background: var(--panel); }
.book-places a { color: var(--gold); font-weight: 700; text-underline-offset: 3px; }
.book-places p { margin: 4px 0 0; color: var(--quiet); font-size: 14px; }

.library-footer { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 18px; padding: 18px clamp(20px, 5vw, 72px); border-top: 1px solid #584257; color: var(--quiet); font-size: 13px; }
.library-footer p { margin: 0; }

@media (max-width: 700px) {
  .library-hero { grid-template-columns: 1fr; min-height: 0; gap: 21px; }
  .library-featured { width: min(95%, 460px); justify-self: center; }
  .library-controls { grid-template-columns: 1fr; }
  .library-shelf ul { grid-template-columns: repeat(auto-fill, minmax(min(100%, 123px), 1fr)); }
  .book-stand { --cover-height: calc(var(--stand-height) - 24px); padding: 16px 11px 0; }
}
@media (max-width: 540px) {
  .book-detail { grid-template-columns: 1fr; }
  .book-display { width: min(59%, 235px); justify-self: center; }
  .book-display .book-cover { max-width: 160px; }
}
@media (prefers-reduced-motion: reduce) {
  .library-featured a { transition: none; }
}

.book-cover[data-cover-ready] .book-cover-fallback { visibility: hidden; }
.book-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f080d75, #f4d7aa30 2%, transparent 5%, transparent 96%, #0f080d45);
  pointer-events: none;
}
.book-stand { perspective: 620px; }
.book-stand .book-cover {
  transform-origin: left center;
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.library-book a:is(:hover, :focus-visible) .book-cover {
  transform: translateY(-4px) rotateY(-9deg);
  box-shadow: 3px 0 #695349, 6px 1px #d4bd9c, 8px 2px #9c836e, 10px 3px #3f2c33, 12px 9px 17px #100910bc;
}

.book-actions > .library-preview-open {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--paper);
  background: var(--panel);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.book-actions > .library-preview-open:hover { color: var(--gold); border-color: var(--gold); }
.library-preview {
  width: min(920px, calc(100% - 26px));
  max-height: calc(100dvh - 24px);
  padding: clamp(12px, 2.5vw, 22px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--paper);
  box-shadow: 0 22px 66px #0b0710ba;
}
.library-preview::backdrop { background: #0c0813ce; }
.library-preview header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.library-preview h2 { margin: 0; font: 650 clamp(21px, 3vw, 32px)/1.2 var(--heading); }
.library-preview header button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--night);
  color: var(--paper);
  cursor: pointer;
  font-size: 26px;
}
.library-preview header button:hover { color: var(--gold); border-color: var(--gold); }
.library-preview-viewer {
  height: clamp(270px, 64dvh, 615px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--night);
}
.library-preview-content { display: block; width: 100%; height: 100%; border: 0; }
.library-preview-status { margin-bottom: 8px; color: var(--quiet); }
.library-preview-status:empty { display: none; }
.library-preview-source { display: inline-flex; align-items: center; min-height: 44px; gap: 7px; color: var(--gold); text-underline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  .book-stand .book-cover { transition: none; }
  .library-book a:is(:hover, :focus-visible) .book-cover { transform: none; }
}

.book-category a, .book-edition a { text-decoration-color: var(--line); text-underline-offset: 3px; }
.book-category a:hover, .book-edition a:hover { text-decoration-color: var(--gold); }
.book-topics { margin-top: clamp(29px, 5vw, 55px); }
.book-topics h2 { margin: 0 0 15px; font: 650 clamp(20px, 3vw, 28px)/1.2 var(--heading); color: #f3e0c7; }
.book-topics dl { display: grid; gap: 8px; margin: 0; }
.book-topics :is(dt, dd) { margin: 0; }
.book-topics dt { color: var(--quiet); font-size: 13px; }
.book-topics dd { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 4px; }
.book-topics a {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--paper);
  font-size: 13px;
  text-decoration: none;
}
.book-topics a:hover { border-color: var(--gold); color: var(--gold); }

.book-share { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; margin-top: 12px; }
.book-share button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--paper);
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
}
.book-share button:hover { color: var(--gold); border-color: var(--gold); }
.book-share [role="status"] { color: var(--quiet); font-size: 13px; }
.book-share input {
  flex-basis: 100%;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--night);
  color: var(--paper);
}

.book-rating { margin: 13px 0 16px; }
.book-rating p { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; margin: 0; color: var(--quiet); font-size: 14px; }
.book-rating strong { color: var(--paper); font-size: 15px; }
.book-rating-stars { position: relative; display: inline-block; color: #9c82a5; font: 700 21px/1.2 system-ui, sans-serif; letter-spacing: .08em; }
.book-rating-stars span + span { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: var(--gold); white-space: nowrap; }
.book-rating ul { display: flex; flex-wrap: wrap; gap: 4px 13px; margin: 3px 0 0; padding: 0; list-style: none; }
.book-rating li { color: var(--quiet); font-size: 12px; }
.book-rating li a { text-decoration-color: var(--line); text-underline-offset: 3px; }
.book-rating li a:hover { color: var(--gold); }
.book-rating-empty { margin: 11px 0; color: var(--quiet); font-size: 13px; }

.paired-covers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 12px; width: 100%; }
.paired-cover { display: grid; gap: 8px; text-align: center; color: var(--quiet); font-size: 13px; }
.book-stand--paired { padding-inline: 9px; }
.book-stand--paired .book-cover, .book-display--paired .book-cover { width: 100%; }
.book-display--paired { padding-inline: clamp(12px, 2vw, 23px); }
.edition-package { max-width: 680px; margin: 32px 0 0; }
.edition-package img { display: block; width: 100%; height: auto; border-radius: 7px; }
.edition-package figcaption { margin-top: 7px; color: var(--quiet); font-size: 13px; }
@media (max-width: 540px) {
  .book-display--paired { width: min(100%, 355px); }
}

@media (max-width: 400px) {
  .library-brand img { width: 90px; }
  .library-nav { gap: 9px; font-size: 13px; }
  .lang-switcher--catalogue .lang-switcher-toggle { padding: 5px 8px; }
}

.lang-switcher--catalogue { position: relative; }
.lang-switcher--catalogue .lang-switcher-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--quiet);
  font-size: 13px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.lang-switcher--catalogue .lang-switcher-toggle::-webkit-details-marker { display: none; }
.lang-switcher--catalogue[open] .lang-switcher-toggle,
.lang-switcher--catalogue .lang-switcher-toggle:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.lang-switcher--catalogue .lang-switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 2px;
  min-width: 170px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #1e1524;
  box-shadow: 0 12px 28px #08050cb8;
}
.library-nav .lang-switcher--catalogue .lang-switcher-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 5px;
  color: var(--paper);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
}
.library-nav .lang-switcher--catalogue .lang-switcher-menu a:hover {
  background: #33223a;
  color: var(--gold);
}
.library-nav .lang-switcher--catalogue .lang-switcher-menu a[aria-current="true"] {
  background: #472c39;
  color: var(--gold);
  font-weight: 700;
}
.lang-switcher--catalogue .lang-code {
  color: var(--quiet);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}
.lang-switcher--catalogue .lang-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.lang-flag {
  display: block;
  width: 18px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.24);
}
.lang-switcher--catalogue a[aria-current="true"] .lang-code { color: var(--gold); }

.book-language-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid #9e794c;
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  background: linear-gradient(135deg, #2d202b, #231826);
  color: var(--paper);
  font-size: 14px;
  line-height: 1.48;
}
.book-language-notice-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: #efc98e1f;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}
.book-language-notice p { margin: 0; }
