/* =========================================================
   Gamaneh Library
   Unified list + detail stylesheet
   Scope: body.library-body
   ========================================================= */

/* =========================================================
   Theme and base
   ========================================================= */

body.library-body {
  --library-max: var(--g-container, 1320px);
  --library-header-height: var(--g-header-height, 82px);

  --library-bg: #030303;
  --library-bg-soft: #090807;
  --library-panel: rgba(10, 9, 8, 0.72);
  --library-panel-strong: rgba(15, 13, 10, 0.88);

  --library-text: var(--g-cream, #f2ecdf);
  --library-text-strong: #fffaf0;
  --library-text-muted: rgba(242, 236, 223, 0.66);
  --library-text-faint: rgba(242, 236, 223, 0.46);

  --library-gold: var(--g-gold, #f4bd48);
  --library-gold-light: var(--g-gold-2, #ffd36a);
  --library-copper: var(--g-copper-2, #d8893a);
  --library-success: var(--g-success, #8fcf7a);

  --library-border: rgba(255, 255, 255, 0.10);
  --library-border-gold: rgba(244, 189, 72, 0.22);

  color: var(--library-text);
  background:
    radial-gradient(circle at 16% 8%, rgba(244, 189, 72, 0.08), transparent 28%),
    radial-gradient(circle at 84% 5%, rgba(184, 115, 51, 0.10), transparent 30%),
    linear-gradient(180deg, var(--library-bg), var(--library-bg-soft) 44%, var(--library-bg));
  overflow-x: hidden;
}

body.library-body::before,
body.library-body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body.library-body::before {
  z-index: -4;
  opacity: 0.08;
  background-image:
    linear-gradient(rgba(244, 189, 72, 0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 189, 72, 0.08) 1px, transparent 1px);
  background-size: 96px 96px;
  mask-image: radial-gradient(circle at center, #000 0%, transparent 78%);
}

body.library-body::after {
  z-index: -3;
  opacity: 0.30;
  background:
    radial-gradient(circle at 50% 120%, rgba(244, 189, 72, 0.10), transparent 36%),
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.014),
      transparent 34%,
      transparent 66%,
      rgba(255, 255, 255, 0.014)
    );
}

body.library-body .library-container {
  width: min(var(--library-max), calc(100% - 40px));
  margin-inline: auto;
}

/* =========================================================
   Direction helpers
   ========================================================= */

/*
 * Put dir="auto" on the HTML element containing dynamic text.
 * text-align:start then means:
 * RTL text -> right
 * LTR text -> left
 */
body.library-body .library-auto,
body.library-body [dir="auto"] {
  min-width: 0;
  max-width: 100%;
  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
  word-break: normal;
}

body.library-body .library-justify {
  text-align: justify;
  text-align-last: start;
}

body.library-body .library-ltr,
body.library-body .ltr,
body.library-body [dir="ltr"] {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

body.library-body .library-rtl,
body.library-body [dir="rtl"] {
  direction: rtl;
  text-align: right;
  unicode-bidi: isolate;
}

/* =========================================================
   Shared decorative layers
   ========================================================= */

body.library-body .library-section-bg,
body.library-body .library-section-overlay,
body.library-body .library-section-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

body.library-body .library-section-bg {
  z-index: -5;
  overflow: hidden;
  background:
    radial-gradient(circle at 70% 20%, rgba(244, 189, 72, 0.07), transparent 28%),
    radial-gradient(circle at 20% 88%, rgba(184, 115, 51, 0.11), transparent 34%),
    linear-gradient(180deg, #030303, #090909 54%, #030303);
}

body.library-body .library-section-overlay {
  z-index: -4;
  background:
    radial-gradient(circle at 24% 46%, rgba(244, 189, 72, 0.07), transparent 28%),
    linear-gradient(
      90deg,
      rgba(3, 3, 3, 0.70),
      rgba(3, 3, 3, 0.38) 30%,
      rgba(3, 3, 3, 0.10) 58%,
      rgba(3, 3, 3, 0.40)
    ),
    linear-gradient(180deg, rgba(3, 3, 3, 0.32), transparent 40%, rgba(3, 3, 3, 0.72));
}

body.library-body .library-section-noise {
  z-index: -3;
  opacity: 0.09;
  mix-blend-mode: screen;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.80) 0 1px, transparent 1.4px),
    radial-gradient(circle at 80% 30%, rgba(244, 189, 72, 0.72) 0 1px, transparent 1.6px),
    radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.58) 0 1px, transparent 1.4px);
  background-size: 88px 88px, 132px 132px, 174px 174px;
}

body.library-body .library-section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin-bottom: 13px;
  color: var(--library-gold);
  font-size: 0.76rem;
  font-weight: 950;
  line-height: 1.5;
}

body.library-body .library-section-eyebrow::before {
  content: "";
  width: 32px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--library-gold));
  box-shadow: 0 0 18px rgba(244, 189, 72, 0.42);
}

body.library-body .library-section-eyebrow::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--library-gold-light);
  box-shadow: 0 0 16px rgba(244, 189, 72, 0.72);
}

/* =========================================================
   Buttons
   ========================================================= */

body.library-body .library-btn-primary,
body.library-body .library-btn-secondary,
body.library-body .library-board-admin-link,
body.library-body .library-detail-back-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 20px;
  border-radius: 14px;
  font-size: 0.82rem;
  font-weight: 950;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  transition:
    transform 220ms ease,
    color 220ms ease,
    border-color 220ms ease,
    background 220ms ease,
    box-shadow 220ms ease;
}

body.library-body .library-btn-primary {
  border: 1px solid rgba(255, 211, 106, 0.72);
  color: #080706;
  background:
    linear-gradient(135deg, var(--library-gold-light), var(--library-gold), var(--library-copper));
  box-shadow:
    0 16px 42px rgba(244, 189, 72, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

body.library-body .library-btn-primary:hover {
  color: #080706;
  transform: translateY(-2px);
  box-shadow:
    0 24px 58px rgba(244, 189, 72, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.50);
}

body.library-body .library-btn-secondary,
body.library-body .library-board-admin-link,
body.library-body .library-detail-back-button {
  border: 1px solid rgba(244, 189, 72, 0.34);
  color: var(--library-gold);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.052), rgba(255, 255, 255, 0.014)),
    rgba(5, 5, 5, 0.48);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

body.library-body .library-btn-secondary:hover,
body.library-body .library-board-admin-link:hover,
body.library-body .library-detail-back-button:hover {
  color: #080706;
  border-color: var(--library-gold);
  background: var(--library-gold);
  transform: translateY(-2px);
  box-shadow: 0 18px 46px rgba(244, 189, 72, 0.20);
}

/* =========================================================
   List hero
   ========================================================= */

body.library-body .library-hero-section {
  position: relative;
  min-height: 100svh;
  padding: calc(var(--library-header-height) + 64px) 0 88px;
  display: flex;
  align-items: center;
  isolation: isolate;
  overflow: hidden;
  background: var(--library-bg);
}

body.library-body .library-hero-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(300px, 0.56fr);
  align-items: center;
  gap: clamp(30px, 5vw, 82px);
}

body.library-body .library-hero-content {
  max-width: 730px;
}

body.library-body .library-hero-content h1 {
  margin: 0 0 16px;
  color: #d7bd86;
  font-size: clamp(3.6rem, 7vw, 7.2rem);
  font-weight: 950;
  line-height: 0.90;
  letter-spacing: -4px;
  text-shadow:
    0 28px 78px rgba(0, 0, 0, 0.96),
    0 0 30px rgba(244, 189, 72, 0.12);
}

body.library-body .library-hero-content h2 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.15rem, 2.1vw, 2.15rem);
  font-weight: 950;
  line-height: 1.55;
  letter-spacing: -0.7px;
}

body.library-body .library-hero-content p {
  max-width: 660px;
  margin: 20px 0 0;
  color: rgba(242, 236, 223, 0.74);
  font-size: 0.86rem;
  line-height: 2.15;
}

body.library-body .library-hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 11px;
  margin-top: 28px;
}

body.library-body .library-hero-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  justify-self: end;
  padding: 18px;
  border: 1px solid var(--library-border);
  border-radius: 26px;
  background:
    radial-gradient(circle at 100% 0%, rgba(244, 189, 72, 0.11), transparent 34%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.016)),
    rgba(7, 7, 7, 0.50);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow:
    0 32px 100px rgba(0, 0, 0, 0.68),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

body.library-body .library-hero-panel::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(244, 189, 72, 0.09);
  border-radius: 20px;
  pointer-events: none;
}

body.library-body .library-hero-artwork {
  position: relative;
  width: 100%;
  min-height: clamp(430px, 46vw, 520px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(244, 189, 72, 0.16);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 48%, rgba(244, 189, 72, 0.16), transparent 51%),
    radial-gradient(circle at 72% 18%, rgba(184, 115, 51, 0.10), transparent 31%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.052), rgba(255, 255, 255, 0.010)),
    rgba(0, 0, 0, 0.24);
  isolation: isolate;
}

body.library-body .library-hero-artwork::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 38px;
  z-index: -1;
  width: min(68%, 280px);
  height: 52px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  filter: blur(22px);
  transform: translateX(-50%);
}

body.library-body .library-hero-artwork__glow {
  position: absolute;
  inset: 14%;
  z-index: -1;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(244, 189, 72, 0.18), rgba(184, 115, 51, 0.08) 42%, transparent 72%);
  filter: blur(46px);
}

body.library-body .library-hero-artwork > svg,
body.library-body .library-books-stack {
  position: relative;
  z-index: 2;
  width: min(100%, 430px);
  height: auto;
  max-height: 500px;
  display: block;
  overflow: visible;
  filter:
    drop-shadow(0 28px 34px rgba(0, 0, 0, 0.58))
    drop-shadow(0 0 20px rgba(244, 189, 72, 0.09));
}

body.library-body .library-scroll-indicator {
  position: absolute;
  right: 50%;
  bottom: 25px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(242, 236, 223, 0.58);
  font-size: 0.71rem;
  font-weight: 850;
  transform: translateX(50%);
}

body.library-body .library-scroll-indicator i {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--library-gold);
  border: 1px solid rgba(244, 189, 72, 0.34);
  border-radius: 50%;
  animation: libraryScrollFloat 1.6s ease-in-out infinite;
}

body.library-body .library-scroll-indicator i::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
}

/* =========================================================
   Hero statistics
   ========================================================= */

body.library-body .library-hero-stats {
  width: 100%;
  max-width: 720px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

body.library-body .library-hero-stat-card {
  position: relative;
  min-width: 0;
  min-height: 80px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 11px;
  overflow: hidden;
  border: 1px solid rgba(244, 189, 72, 0.17);
  border-radius: 17px;
  background:
    radial-gradient(circle at 100% 0%, rgba(244, 189, 72, 0.10), transparent 45%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.050), rgba(255, 255, 255, 0.012)),
    rgba(5, 5, 5, 0.44);
  box-shadow:
    0 18px 46px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

body.library-body .library-hero-stat-card__icon {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(244, 189, 72, 0.34);
  border-radius: 13px;
  color: var(--library-gold);
  background:
    radial-gradient(circle at 50% 28%, rgba(244, 189, 72, 0.17), transparent 65%),
    rgba(244, 189, 72, 0.04);
  font-family: var(--g-font-number, inherit);
  font-size: 0.77rem;
  font-weight: 950;
}

body.library-body .library-hero-stat-card__content {
  min-width: 0;
  display: grid;
  gap: 4px;
}

body.library-body .library-hero-stat-card__content strong {
  direction: ltr;
  display: block;
  color: var(--library-text-strong);
  font-family: var(--g-font-number, inherit);
  font-size: 1.14rem;
  font-weight: 950;
  line-height: 1.15;
  text-align: right;
}

body.library-body .library-hero-stat-card__content small {
  color: rgba(242, 236, 223, 0.61);
  font-size: 0.66rem;
  font-weight: 750;
}

/* =========================================================
   Resources board and filters
   ========================================================= */

body.library-body .library-resources-section {
  position: relative;
  padding: 92px 0;
  background:
    radial-gradient(circle at 82% 18%, rgba(244, 189, 72, 0.09), transparent 30%),
    radial-gradient(circle at 16% 82%, rgba(184, 115, 51, 0.09), transparent 34%),
    linear-gradient(180deg, #030303, #090909 52%, #030303);
}

body.library-body .library-board {
  position: relative;
  z-index: 1;
  padding: clamp(18px, 2.6vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 30px;
  background:
    radial-gradient(circle at 78% 12%, rgba(244, 189, 72, 0.11), transparent 30%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.022)),
    rgba(7, 7, 7, 0.56);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
  box-shadow:
    0 38px 128px rgba(0, 0, 0, 0.70),
    0 0 58px rgba(244, 189, 72, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

body.library-body .library-board__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 25px;
  padding-bottom: 23px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

body.library-body .library-board-title h2 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.38rem, 2.15vw, 2.12rem);
  font-weight: 950;
  line-height: 1.42;
  letter-spacing: -0.8px;
}

body.library-body .library-board-title p {
  max-width: 760px;
  margin: 11px 0 0;
  color: rgba(242, 236, 223, 0.63);
  font-size: 0.82rem;
  line-height: 2.05;
}

body.library-body .library-filter-form {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 11px;
  align-items: end;
  margin-bottom: 30px;
  padding: 15px;
  border: 1px solid rgba(244, 189, 72, 0.17);
  border-radius: 24px;
  background:
    radial-gradient(circle at 100% 0%, rgba(244, 189, 72, 0.11), transparent 34%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.064), rgba(255, 255, 255, 0.016)),
    rgba(5, 5, 5, 0.64);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.40),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

body.library-body .library-filter-field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

body.library-body .library-filter-field--search,
body.library-body .library-filter-field--category {
  grid-column: span 4;
}

body.library-body .library-filter-field--type,
body.library-body .library-filter-field--language {
  grid-column: span 2;
}

body.library-body .library-filter-field--availability {
  grid-column: span 4;
}

body.library-body .library-filter-actions {
  grid-column: span 8;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

body.library-body .library-filter-field label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  color: rgba(255, 211, 106, 0.92);
  font-size: 0.70rem;
  font-weight: 950;
}

body.library-body .library-filter-field label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--library-gold);
  box-shadow: 0 0 14px rgba(244, 189, 72, 0.62);
}

body.library-body .library-filter-field input,
body.library-body .library-filter-field select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 15px;
  color: rgba(242, 236, 223, 0.92);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.052), rgba(255, 255, 255, 0.014)),
    rgba(8, 8, 8, 0.76);
  outline: none;
  font-size: 0.78rem;
  font-weight: 750;
  direction: rtl;
  text-align: right;
  transition:
    border-color 220ms ease,
    box-shadow 220ms ease,
    background 220ms ease;
}

body.library-body .library-filter-field input::placeholder {
  color: rgba(242, 236, 223, 0.34);
}

body.library-body .library-filter-field select {
  appearance: none;
  -webkit-appearance: none;
  padding-left: 38px;
  color-scheme: dark;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255, 211, 106, 0.92) 50%),
    linear-gradient(135deg, rgba(255, 211, 106, 0.92) 50%, transparent 50%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.052), rgba(255, 255, 255, 0.014));
  background-position: left 20px center, left 13px center, center;
  background-size: 7px 7px, 7px 7px, 100% 100%;
  background-repeat: no-repeat;
}

body.library-body .library-filter-field select option {
  color: #f2ecdf;
  background: #11100d;
}

body.library-body .library-filter-field input:focus,
body.library-body .library-filter-field select:focus {
  border-color: rgba(255, 211, 106, 0.72);
  box-shadow:
    0 0 0 4px rgba(244, 189, 72, 0.10),
    0 0 30px rgba(244, 189, 72, 0.11);
}

body.library-body .library-filter-submit,
body.library-body .library-filter-reset {
  min-width: 108px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 15px;
  font-size: 0.79rem;
  font-weight: 950;
}

body.library-body .library-filter-submit {
  border: 1px solid rgba(255, 211, 106, 0.72);
  color: #080706;
  background:
    linear-gradient(135deg, var(--library-gold-light), var(--library-gold), var(--library-copper));
}

body.library-body .library-filter-reset {
  border: 1px solid rgba(244, 189, 72, 0.36);
  color: var(--library-gold);
  background: rgba(244, 189, 72, 0.05);
}

/* =========================================================
   Resource cards
   ========================================================= */

body.library-body .library-resource-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 17px;
}

body.library-body .library-resource-card {
  position: relative;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  border: 1px solid rgba(244, 189, 72, 0.16);
  border-radius: 24px;
  color: var(--library-text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.070), rgba(255, 255, 255, 0.014)),
    radial-gradient(circle at 70% 0%, rgba(244, 189, 72, 0.11), transparent 34%),
    rgba(7, 7, 7, 0.64);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 26px 78px rgba(0, 0, 0, 0.50),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition:
    transform 260ms ease,
    border-color 260ms ease,
    box-shadow 260ms ease;
}

body.library-body .library-resource-card:hover {
  transform: translateY(-6px);
  border-color: rgba(255, 211, 106, 0.38);
  box-shadow:
    0 36px 104px rgba(0, 0, 0, 0.68),
    0 0 44px rgba(244, 189, 72, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

body.library-body .library-resource-card__glow {
  position: absolute;
  inset: -30%;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 24%, rgba(244, 189, 72, 0.15), transparent 26%),
    linear-gradient(180deg, rgba(244, 189, 72, 0.05), transparent 48%);
  transition: opacity 260ms ease;
}

body.library-body .library-resource-card:hover .library-resource-card__glow {
  opacity: 1;
}

body.library-body .library-resource-card > *:not(.library-resource-card__glow) {
  position: relative;
  z-index: 1;
}

body.library-body .library-resource-card__top {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 15px 15px 0;
}

body.library-body .library-resource-cover {
  width: 70px;
  height: 94px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(255, 211, 106, 0.38);
  border-radius: 17px;
  color: var(--library-gold);
  background:
    radial-gradient(circle at 50% 26%, rgba(255, 211, 106, 0.18), transparent 58%),
    linear-gradient(145deg, rgba(244, 189, 72, 0.10), rgba(255, 255, 255, 0.022)),
    rgba(0, 0, 0, 0.36);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.36),
    0 0 20px rgba(244, 189, 72, 0.10);
}

body.library-body .library-resource-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.library-body .library-resource-cover span {
  font-size: 1.8rem;
  font-weight: 950;
}

body.library-body .library-resource-heading {
  min-width: 0;
}

body.library-body .library-resource-code {
  direction: ltr;
  unicode-bidi: isolate;

  width: fit-content;
  max-width: 100%;
  min-height: 23px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  margin-bottom: 7px;
  padding: 4px 8px;

  overflow: hidden;
  border-radius: 999px;

  color: #080706;
  background:
    linear-gradient(
      135deg,
      var(--library-gold-light),
      var(--library-copper)
    );

  font-family: var(--g-font-number, inherit);

  /* کوچک‌تر شدن متن کد */
  font-size: clamp(0.48rem, 0.45rem + 0.08vw, 0.56rem);
  font-weight: 850;
  line-height: 1;

  /* جلوگیری از باز شدن بیش از اندازه متن */
  letter-spacing: -0.18px;
  white-space: nowrap;
  text-overflow: ellipsis;

  box-shadow:
    0 10px 24px rgba(244, 189, 72, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

body.library-body .library-resource-title {
  min-width: 0;
  margin: 0;
}

/*
 * No centering.
 * dir="auto" decides right/left direction.
 * Three lines keep all cards visually balanced.
 */
body.library-body .library-resource-title a {
  width: 100%;
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  max-height: 5.25em;

  color: var(--library-text-strong);
  font-size: clamp(0.77rem, 0.72rem + 0.18vw, 0.92rem);
  font-weight: 850;
  line-height: 1.75;
  letter-spacing: -0.03px;

  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
  text-decoration: none;
}

body.library-body .library-resource-title a:hover {
  color: var(--library-gold-light);
}

body.library-body .library-resource-title a:focus-visible {
  outline: 2px solid rgba(255, 211, 106, 0.82);
  outline-offset: 4px;
  border-radius: 5px;
}

body.library-body .library-resource-subtitle {
  width: 100%;
  min-width: 0;
  display: -webkit-box;
  margin: 6px 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  max-height: 3.6em;

  color: rgba(242, 236, 223, 0.55);
  font-size: 0.68rem;
  font-weight: 650;
  line-height: 1.8;

  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
  hyphens: auto;
}

body.library-body .library-resource-meta {
  display: grid;
  gap: 7px;
  margin: 0 15px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-radius: 17px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.034), rgba(255, 255, 255, 0.010)),
    rgba(0, 0, 0, 0.22);
}

body.library-body .library-resource-meta__row {
  min-width: 0;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 2px 0;
  color: rgba(242, 236, 223, 0.64);
  font-size: 0.69rem;
  line-height: 1.82;
}

body.library-body .library-resource-meta__row b {
  direction: rtl;
  min-width: 0;
  color: rgba(255, 211, 106, 0.90);
  font-size: 0.66rem;
  font-weight: 950;
  text-align: right;
  unicode-bidi: isolate;
}

body.library-body .library-resource-meta__row > span {
  width: 100%;
  min-width: 0;
  display: block;
  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
  word-break: normal;
}

body.library-body .library-resource-meta__row > .library-ltr,
body.library-body .library-resource-meta__row > .ltr {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

body.library-body .library-resource-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: auto 15px 0;
  padding-top: 2px;
}

body.library-body .library-resource-tags span {
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid rgba(244, 189, 72, 0.15);
  border-radius: 999px;
  color: rgba(242, 236, 223, 0.75);
  background:
    linear-gradient(145deg, rgba(244, 189, 72, 0.065), rgba(255, 255, 255, 0.020)),
    rgba(255, 255, 255, 0.028);
  font-size: 0.64rem;
  font-weight: 850;
}

body.library-body .library-resource-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
  padding: 13px 15px 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.075);
  background: linear-gradient(180deg, transparent, rgba(244, 189, 72, 0.03));
}

body.library-body .library-resource-action {
  min-height: 33px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border: 1px solid rgba(244, 189, 72, 0.28);
  border-radius: 999px;
  color: var(--library-gold);
  background: rgba(244, 189, 72, 0.05);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

body.library-body .library-resource-action:hover {
  color: #080706;
  border-color: var(--library-gold);
  background: var(--library-gold);
  transform: translateY(-2px);
}

body.library-body .library-resource-action--detail,
body.library-body .library-resource-action--primary {
  color: #080706;
  border-color: rgba(255, 211, 106, 0.72);
  background:
    linear-gradient(135deg, var(--library-gold-light), var(--library-gold), var(--library-copper));
}

body.library-body .library-resource-action--admin {
  border-color: rgba(143, 207, 122, 0.36);
  color: var(--library-success);
  background: rgba(143, 207, 122, 0.07);
}

body.library-body .library-empty-state {
  padding: 46px 22px;
  text-align: center;
  border: 1px dashed rgba(244, 189, 72, 0.28);
  border-radius: 22px;
  background: rgba(244, 189, 72, 0.03);
}

body.library-body .library-empty-state strong {
  display: block;
  margin-bottom: 9px;
  color: #fff;
  font-size: 1rem;
  font-weight: 950;
}

body.library-body .library-empty-state p {
  max-width: 540px;
  margin: 0 auto 18px;
  color: rgba(242, 236, 223, 0.61);
  font-size: 0.82rem;
  line-height: 2;
}

/* =========================================================
   Pagination
   ========================================================= */

body.library-body .library-pagination {
  margin-top: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

body.library-body .library-page-link,
body.library-body .library-page-current {
  min-width: 43px;
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 13px;
  font-size: 0.78rem;
  font-weight: 950;
}

body.library-body .library-page-link {
  border: 1px solid rgba(244, 189, 72, 0.32);
  color: var(--library-gold);
  background: rgba(255, 255, 255, 0.03);
}

body.library-body .library-page-current {
  direction: ltr;
  color: #080706;
  border: 1px solid rgba(255, 211, 106, 0.72);
  background:
    linear-gradient(135deg, var(--library-gold-light), var(--library-gold), var(--library-copper));
}

/* =========================================================
   Detail page hero
   ========================================================= */

body.library-detail-body {
  background:
    radial-gradient(circle at 82% 8%, rgba(244, 189, 72, 0.09), transparent 28%),
    radial-gradient(circle at 12% 70%, rgba(184, 115, 51, 0.08), transparent 34%),
    #030303;
}

body.library-body .library-detail-page {
  position: relative;
  padding: calc(var(--library-header-height) + 40px) 0 32px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 84% 16%, rgba(244, 189, 72, 0.09), transparent 29%),
    linear-gradient(180deg, #030303, #080706);
}

body.library-body .library-detail-breadcrumb {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 17px;
  color: var(--library-text-faint);
  font-size: 0.70rem;
  font-weight: 750;
}

body.library-body .library-detail-breadcrumb a {
  color: rgba(255, 211, 106, 0.82);
}

body.library-body .library-detail-hero-card {
  position: relative;
  z-index: 1;
  min-height: 470px;
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(0, 1fr);
  grid-template-areas: "visual content";
  align-items: stretch;
  gap: clamp(26px, 4vw, 60px);
  padding: clamp(19px, 3vw, 34px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 31px;
  background:
    radial-gradient(circle at 15% 22%, rgba(244, 189, 72, 0.10), transparent 34%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.068), rgba(255, 255, 255, 0.014)),
    rgba(7, 7, 7, 0.64);
  backdrop-filter: blur(23px);
  -webkit-backdrop-filter: blur(23px);
  box-shadow:
    0 36px 112px rgba(0, 0, 0, 0.64),
    0 0 56px rgba(244, 189, 72, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

body.library-body .library-detail-hero-card::before {
  content: "";
  position: absolute;
  inset: 11px;
  border: 1px solid rgba(244, 189, 72, 0.07);
  border-radius: 24px;
  pointer-events: none;
}

body.library-body .library-detail-copy {
  grid-area: content;
  min-width: 0;
  align-self: center;
  padding-block: 10px;
}

body.library-body .library-detail-code {
  direction: ltr;
  width: fit-content;
  max-width: 100%;
  min-height: 29px;
  display: inline-flex;
  align-items: center;
  margin-bottom: 14px;
  padding: 6px 11px;
  overflow: hidden;
  border: 1px solid rgba(255, 211, 106, 0.54);
  border-radius: 999px;
  color: #080706;
  background:
    linear-gradient(135deg, var(--library-gold-light), var(--library-gold), var(--library-copper));
  font-family: var(--g-font-number, inherit);
  font-size: 0.64rem;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: isolate;
}

/* =========================================================
   Detail main title
   ========================================================= */

body.library-body .library-detail-title {
  width: 100%;
  max-width: 820px;
  min-width: 0;

  margin: 0;

  color: var(--library-text-strong);

  /*
   * اندازه متعادل برای عنوان‌های بلند فارسی و انگلیسی
   */
  font-size: clamp(1.28rem, 2.05vw, 2.30rem);
  font-weight: 800;
  line-height: 1.52;
  letter-spacing: -0.025em;

  /*
   * خطوط کامل Justify می‌شوند.
   * خط آخر براساس جهت زبان در ابتدا قرار می‌گیرد.
   */
  text-align: justify;
  text-align-last: start;
  text-justify: inter-word;

  /*
   * جهت متن توسط dir="auto" در قالب تشخیص داده می‌شود.
   */
  unicode-bidi: plaintext;

  /*
   * جلوگیری از بیرون‌زدگی عنوان‌های بسیار بلند
   */
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;

  text-shadow:
    0 20px 56px rgba(0, 0, 0, 0.86),
    0 0 20px rgba(244, 189, 72, 0.07);
}

body.library-body .library-detail-title:dir(rtl) {
  letter-spacing: -0.025em;
}

body.library-body .library-detail-title:dir(ltr) {
  letter-spacing: -0.015em;
}

body.library-body .library-detail-subtitle {
  max-width: 760px;
  margin: 15px 0 0;
  color: rgba(242, 236, 223, 0.65);
  font-size: 0.86rem;
  line-height: 2;
  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
}

body.library-body .library-detail-original-title {
  max-width: 760px;
  display: grid;
  gap: 6px;
  margin-top: 16px;
  padding: 12px 14px;
  border-inline-start: 3px solid var(--library-gold);
  border-radius: 12px;
  background:
    linear-gradient(90deg, rgba(244, 189, 72, 0.05), transparent);
}

body.library-body .library-detail-original-title span {
  color: rgba(255, 211, 106, 0.80);
  font-size: 0.64rem;
  font-weight: 950;
}

body.library-body .library-detail-original-title strong {
  min-width: 0;
  color: rgba(255, 250, 240, 0.88);
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.8;
  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
}

body.library-body .library-detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 20px;
}

body.library-body .library-detail-badges span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(244, 189, 72, 0.17);
  border-radius: 999px;
  color: rgba(255, 211, 106, 0.90);
  background:
    linear-gradient(145deg, rgba(244, 189, 72, 0.07), rgba(255, 255, 255, 0.016)),
    rgba(0, 0, 0, 0.24);
  font-size: 0.65rem;
  font-weight: 900;
}

body.library-body .library-detail-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}

body.library-body .library-detail-summary__item {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.032), rgba(255, 255, 255, 0.008)),
    rgba(0, 0, 0, 0.20);
}

body.library-body .library-detail-summary__item small {
  direction: rtl;
  color: rgba(255, 211, 106, 0.66);
  font-size: 0.60rem;
  font-weight: 900;
  text-align: right;
  unicode-bidi: isolate;
}

body.library-body .library-detail-summary__item strong {
  width: 100%;
  min-width: 0;
  color: rgba(242, 236, 223, 0.84);
  font-size: 0.70rem;
  font-weight: 800;
  line-height: 1.72;
  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
}

body.library-body .library-detail-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 23px;
}

body.library-body .library-detail-visual {
  grid-area: visual;
  position: relative;
  min-height: 390px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(244, 189, 72, 0.15);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 45%, rgba(244, 189, 72, 0.14), transparent 48%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.040), rgba(255, 255, 255, 0.009)),
    rgba(0, 0, 0, 0.25);
}

body.library-body .library-detail-visual::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 32px;
  width: 200px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.68);
  filter: blur(20px);
  transform: translateX(-50%);
}

body.library-body .library-detail-visual__glow {
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  background: rgba(244, 189, 72, 0.16);
  filter: blur(50px);
}

body.library-body .library-detail-visual > svg,
body.library-body .library-detail-fallback-book {
  position: relative;
  z-index: 2;
  width: min(90%, 320px);
  max-height: 365px;
  display: block;
  object-fit: contain;
  filter:
    drop-shadow(0 28px 30px rgba(0, 0, 0, 0.60))
    drop-shadow(0 0 18px rgba(244, 189, 72, 0.10));
}

body.library-body .library-detail-cover {
  position: relative;
  z-index: 2;
  width: min(82%, 270px);
  aspect-ratio: 0.72;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 211, 106, 0.32);
  border-radius: 18px;
  background: #090806;
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.62),
    0 0 28px rgba(244, 189, 72, 0.11);
}

body.library-body .library-detail-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* =========================================================
   Detail content
   ========================================================= */

body.library-body .library-detail-content-section {
  position: relative;
  padding: 24px 0 96px;
  background:
    radial-gradient(circle at 86% 15%, rgba(244, 189, 72, 0.05), transparent 28%),
    linear-gradient(180deg, #080706, #030303);
}

body.library-body .library-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 310px);
  grid-template-areas: "main sidebar";
  align-items: start;
  gap: 18px;
}

body.library-body .library-detail-main {
  grid-area: main;
  min-width: 0;
  display: grid;
  gap: 17px;
}

body.library-body .library-detail-sidebar {
  grid-area: sidebar;
  position: sticky;
  top: calc(var(--library-header-height) + 20px);
  min-width: 0;
  display: grid;
  gap: 15px;
}

body.library-body .library-detail-card,
body.library-body .library-detail-side-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    radial-gradient(circle at 100% 0%, rgba(244, 189, 72, 0.07), transparent 36%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.050), rgba(255, 255, 255, 0.012)),
    rgba(7, 7, 7, 0.58);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.065);
}

body.library-body .library-detail-card {
  padding: clamp(17px, 2.4vw, 26px);
  border-radius: 24px;
}

body.library-body .library-detail-side-card {
  padding: 18px;
  border-radius: 20px;
}

body.library-body .library-detail-card__head {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

body.library-body .library-detail-card h2,
body.library-body .library-detail-side-card h2 {
  margin: 0;
  color: var(--library-text-strong);
  font-weight: 950;
  line-height: 1.55;
}

body.library-body .library-detail-card h2 {
  font-size: clamp(1.06rem, 1.7vw, 1.42rem);
}

body.library-body .library-detail-side-card h2 {
  font-size: 0.92rem;
}

body.library-body .library-detail-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

body.library-body .library-detail-info-item {
  min-width: 0;
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 13px;
  border: 1px solid rgba(244, 189, 72, 0.10);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(244, 189, 72, 0.04), rgba(255, 255, 255, 0.009)),
    rgba(0, 0, 0, 0.22);
}

body.library-body .library-detail-info-item > span {
  direction: rtl;
  color: rgba(255, 211, 106, 0.72);
  font-size: 0.63rem;
  font-weight: 950;
  text-align: right;
  unicode-bidi: isolate;
}

body.library-body .library-detail-info-item > strong {
  width: 100%;
  min-width: 0;
  color: rgba(242, 236, 223, 0.87);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.85;
  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
}

body.library-body .library-detail-info-item > strong[dir="ltr"] {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

body.library-body .library-detail-text-blocks {
  display: grid;
  gap: 11px;
}

body.library-body .library-detail-text-block {
  display: grid;
  gap: 8px;
  padding: 15px;
  border: 1px solid rgba(244, 189, 72, 0.10);
  border-radius: 16px;
  background: rgba(244, 189, 72, 0.025);
}

body.library-body .library-detail-text-block h3 {
  direction: rtl;
  margin: 0;
  color: rgba(255, 211, 106, 0.80);
  font-size: 0.70rem;
  font-weight: 950;
  text-align: right;
}

body.library-body .library-detail-text-block p {
  margin: 0;
  color: rgba(242, 236, 223, 0.72);
  font-size: 0.78rem;
  line-height: 2.05;
  white-space: pre-line;
  text-align: justify;
  text-align-last: start;
  unicode-bidi: plaintext;
}

body.library-body .library-detail-keywords {
  padding: 15px;
  border: 1px solid rgba(244, 189, 72, 0.10);
  border-radius: 16px;
  color: rgba(242, 236, 223, 0.70);
  background: rgba(244, 189, 72, 0.025);
  font-size: 0.77rem;
  line-height: 2.05;
  white-space: pre-line;
  text-align: start;
  unicode-bidi: plaintext;
}

body.library-body .library-detail-download-list,
body.library-body .library-detail-link-list {
  display: grid;
  gap: 8px;
}

body.library-body .library-detail-download-item,
body.library-body .library-detail-link-item {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 1px solid rgba(244, 189, 72, 0.13);
  border-radius: 16px;
  color: rgba(242, 236, 223, 0.88);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.036), rgba(255, 255, 255, 0.008)),
    rgba(0, 0, 0, 0.22);
  transition:
    transform 220ms ease,
    border-color 220ms ease,
    background 220ms ease;
}

body.library-body .library-detail-download-item:hover,
body.library-body .library-detail-link-item:hover {
  color: rgba(242, 236, 223, 0.96);
  border-color: rgba(255, 211, 106, 0.40);
  background:
    linear-gradient(145deg, rgba(244, 189, 72, 0.09), rgba(255, 255, 255, 0.014)),
    rgba(0, 0, 0, 0.27);
  transform: translateY(-2px);
}

body.library-body .library-detail-download-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 211, 106, 0.44);
  border-radius: 12px;
  color: #080706;
  background:
    linear-gradient(135deg, var(--library-gold-light), var(--library-gold), var(--library-copper));
  font-family: Arial, sans-serif;
  font-size: 1.05rem;
  font-weight: 950;
}

body.library-body .library-detail-download-copy,
body.library-body .library-detail-link-item > span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

body.library-body .library-detail-download-item strong,
body.library-body .library-detail-link-item strong {
  color: var(--library-text-strong);
  font-size: 0.73rem;
  font-weight: 950;
  line-height: 1.7;
  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
}

body.library-body .library-detail-download-item small,
body.library-body .library-detail-link-item small {
  color: rgba(242, 236, 223, 0.50);
  font-size: 0.61rem;
  line-height: 1.7;
  text-align: start;
  unicode-bidi: plaintext;
}

body.library-body .library-detail-link-item {
  justify-content: space-between;
}

body.library-body .library-detail-link-item i {
  direction: ltr;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(244, 189, 72, 0.24);
  border-radius: 50%;
  color: var(--library-gold);
  font-family: Arial, sans-serif;
  font-size: 0.84rem;
  font-style: normal;
}

body.library-body .library-detail-empty-inline {
  padding: 16px;
  border: 1px dashed rgba(244, 189, 72, 0.20);
  border-radius: 15px;
  color: rgba(242, 236, 223, 0.52);
  background: rgba(244, 189, 72, 0.022);
  font-size: 0.72rem;
  line-height: 1.9;
  text-align: center;
}

body.library-body .library-detail-taxonomy {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

body.library-body .library-detail-taxonomy span {
  min-height: 29px;
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border: 1px solid rgba(244, 189, 72, 0.16);
  border-radius: 999px;
  color: rgba(255, 211, 106, 0.86);
  background: rgba(244, 189, 72, 0.045);
  font-size: 0.63rem;
  font-weight: 850;
  line-height: 1.5;
  text-align: start;
  unicode-bidi: plaintext;
}

body.library-body .library-detail-taxonomy p,
body.library-body .library-detail-side-card > p {
  margin: 12px 0 0;
  color: rgba(242, 236, 223, 0.51);
  font-size: 0.70rem;
  line-height: 1.95;
}

body.library-body .library-detail-reference-code {
  direction: ltr;
  display: block;
  margin-top: 13px;
  padding: 10px 11px;
  overflow-wrap: anywhere;
  border: 1px solid rgba(255, 211, 106, 0.16);
  border-radius: 12px;
  color: rgba(255, 211, 106, 0.82);
  background: rgba(0, 0, 0, 0.28);
  font-family: var(--g-font-number, monospace);
  font-size: 0.64rem;
  font-weight: 750;
  line-height: 1.8;
  text-align: left;
  unicode-bidi: isolate;
}

body.library-body .library-detail-reference-card .library-board-admin-link {
  width: 100%;
  margin-top: 15px;
}

/* =========================================================
   Animation
   ========================================================= */

body.library-body .library-hero-content,
body.library-body .library-hero-panel,
body.library-body .library-board,
body.library-body .library-resource-card,
body.library-body .library-detail-hero-card,
body.library-body .library-detail-card,
body.library-body .library-detail-side-card {
  animation: libraryReveal 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes libraryReveal {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes libraryScrollFloat {
  0%,
  100% {
    transform: translateY(-2px);
    opacity: 0.72;
  }

  50% {
    transform: translateY(5px);
    opacity: 1;
  }
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1399px) {
  body.library-body .library-resource-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1199px) {
  body.library-body .library-hero-layout {
    grid-template-columns: 1fr;
  }

  body.library-body .library-hero-panel {
    max-width: none;
    justify-self: stretch;
  }

  body.library-body .library-hero-artwork {
    min-height: 470px;
  }

  body.library-body .library-filter-field--search,
  body.library-body .library-filter-field--category {
    grid-column: span 6;
  }

  body.library-body .library-filter-field--type,
  body.library-body .library-filter-field--language,
  body.library-body .library-filter-field--availability {
    grid-column: span 4;
  }

  body.library-body .library-filter-actions {
    grid-column: 1 / -1;
  }

  body.library-body .library-resource-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.library-body .library-detail-hero-card {
    grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
    gap: 28px;
  }

  body.library-body .library-detail-layout {
    grid-template-columns: minmax(0, 1fr) 270px;
  }
}

@media (max-width: 900px) {
  body.library-body {
    --library-header-height: 72px;
  }

  body.library-body .library-container {
    width: min(100% - 30px, var(--library-max));
  }

  body.library-body .library-hero-section {
    min-height: auto;
    padding: 106px 0 76px;
  }

  body.library-body .library-detail-hero-card {
    min-height: auto;
    grid-template-columns: 1fr;
    grid-template-areas:
      "content"
      "visual";
  }

  body.library-body .library-detail-visual {
    min-height: 340px;
  }

  body.library-body .library-detail-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main"
      "sidebar";
  }

  body.library-body .library-detail-sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.library-body .library-detail-reference-card,
  body.library-body .library-detail-back-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 767px) {
  body.library-body .library-container {
    width: min(100% - 22px, var(--library-max));
  }

  body.library-body .library-hero-content h1 {
    font-size: clamp(3.8rem, 14vw, 6.4rem);
    letter-spacing: -3px;
  }

  body.library-body .library-hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  body.library-body .library-btn-primary,
  body.library-body .library-btn-secondary,
  body.library-body .library-board-admin-link {
    width: 100%;
  }

  body.library-body .library-hero-stats {
    max-width: none;
    display: flex;
    gap: 9px;
    padding: 2px 0 8px;
    overflow-x: auto;
    scroll-snap-type: inline mandatory;
  }

  body.library-body .library-hero-stat-card {
    flex: 0 0 166px;
    scroll-snap-align: start;
  }

  body.library-body .library-scroll-indicator {
    display: none;
  }

  body.library-body .library-resources-section {
    padding: 72px 0;
  }

  body.library-body .library-board {
    padding: 15px;
    border-radius: 22px;
  }

  body.library-body .library-board__head {
    flex-direction: column;
    align-items: flex-start;
  }

  body.library-body .library-filter-form {
    grid-template-columns: 1fr;
    padding: 13px;
    border-radius: 20px;
  }

  body.library-body .library-filter-field--search,
  body.library-body .library-filter-field--category,
  body.library-body .library-filter-field--type,
  body.library-body .library-filter-field--language,
  body.library-body .library-filter-field--availability,
  body.library-body .library-filter-actions {
    grid-column: auto;
  }

  body.library-body .library-filter-actions {
    flex-direction: column;
    align-items: stretch;
  }

  body.library-body .library-filter-submit,
  body.library-body .library-filter-reset {
    width: 100%;
  }

  body.library-body .library-resource-grid {
    grid-template-columns: 1fr;
  }

  body.library-body .library-resource-card {
    min-height: auto;
    border-radius: 21px;
  }

  body.library-body .library-detail-title {
    max-width: 100%;
    font-size: clamp(1.22rem, 5.3vw, 1.85rem);
    line-height: 1.62;
    letter-spacing: -0.02em;
  }

  body.library-body .library-detail-summary {
    grid-template-columns: 1fr;
  }

  body.library-body .library-detail-actions {
    flex-direction: column;
    align-items: stretch;
  }

  body.library-body .library-detail-actions .library-btn-primary,
  body.library-body .library-detail-actions .library-btn-secondary {
    width: 100%;
  }

  body.library-body .library-detail-info-grid,
  body.library-body .library-detail-sidebar {
    grid-template-columns: 1fr;
  }

  body.library-body .library-detail-reference-card,
  body.library-body .library-detail-back-button {
    grid-column: auto;
  }
}

@media (max-width: 480px) {
  body.library-body .library-container {
    width: min(100% - 18px, var(--library-max));
  }

  body.library-body .library-hero-content h1 {
    font-size: 3.65rem;
  }

  body.library-body .library-resource-card__top {
    grid-template-columns: 62px minmax(0, 1fr);
    padding: 13px 13px 0;
  }

  body.library-body .library-resource-cover {
    width: 62px;
    height: 84px;
  }

  body.library-body .library-resource-title a {
    font-size: 0.80rem;
    line-height: 1.82;
    max-height: 5.46em;
  }

  body.library-body .library-resource-meta {
    margin-inline: 13px;
  }

  body.library-body .library-resource-meta__row {
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 8px;
  }

  body.library-body .library-resource-actions {
    flex-direction: column;
    padding-inline: 13px;
  }

  body.library-body .library-resource-action {
    width: 100%;
  }

  body.library-body .library-detail-hero-card {
    padding: 13px;
    border-radius: 20px;
  }

  body.library-body .library-detail-title {
    max-width: 100%;
    font-size: clamp(1.12rem, 5.4vw, 1.38rem);
    line-height: 1.68;
    letter-spacing: -0.015em;
  }

  body.library-body .library-detail-visual {
    min-height: 255px;
  }

  body.library-body .library-detail-visual > svg,
  body.library-body .library-detail-fallback-book {
    width: min(90%, 230px);
    max-height: 240px;
  }

  body.library-body .library-detail-download-item,
  body.library-body .library-detail-link-item {
    padding: 10px;
  }

  body.library-body .library-resource-code {
    min-height: 21px;
    padding: 4px 7px;
    font-size: 0.47rem;
    letter-spacing: -0.22px;
  }
}

/* =========================================================
   Accessibility and print
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  body.library-body *,
  body.library-body *::before,
  body.library-body *::after {
    scroll-behavior: auto;
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
    transition-duration: 0.01ms;
  }

  body.library-body .library-scroll-indicator i {
    animation: none;
  }
}

@media print {
  body.library-body {
    color: #000;
    background: #fff;
  }

  body.library-body .library-section-bg,
  body.library-body .library-section-overlay,
  body.library-body .library-section-noise,
  body.library-body .library-scroll-indicator,
  body.library-body .library-filter-form,
  body.library-body .library-resource-actions,
  body.library-body .library-detail-actions,
  body.library-body .library-detail-back-button {
    display: none;
  }

  body.library-body .library-hero-section,
  body.library-body .library-resources-section,
  body.library-body .library-detail-page,
  body.library-body .library-detail-content-section {
    min-height: auto;
    padding: 22px 0;
    background: #fff;
  }

  body.library-body .library-board,
  body.library-body .library-resource-card,
  body.library-body .library-detail-hero-card,
  body.library-body .library-detail-card,
  body.library-body .library-detail-side-card {
    color: #000;
    border: 1px solid #ddd;
    background: #fff;
    box-shadow: none;
  }

  body.library-body .library-detail-layout {
    display: block;
  }

  body.library-body .library-detail-sidebar {
    position: static;
  }
}

/* =========================================================
   Detail expandable summaries
   ========================================================= */

body.library-body .library-detail-expandable {
  position: relative;
  min-width: 0;
}


/*
 * حالت بسته:
 * حدود شش خط از متن نمایش داده می‌شود.
 */
body.library-body .library-detail-expandable__content {
  position: relative;
  width: 100%;
  min-width: 0;

  margin: 0;

  /*
   * براساس line-height فعلی متن:
   * حدود شش خط نمایش داده می‌شود.
   */
  max-height: 12.3em;
  overflow: hidden;

  color: rgba(242, 236, 223, 0.72);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 2.05;

  text-align: justify;
  text-align-last: start;
  unicode-bidi: plaintext;

  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: normal;

  transition:
    max-height 480ms cubic-bezier(0.16, 1, 0.3, 1);
}


/*
 * فارسی از راست و انگلیسی از چپ شروع می‌شود.
 */
body.library-body
.library-detail-expandable__content[dir="rtl"] {
  direction: rtl;
}

body.library-body
.library-detail-expandable__content[dir="ltr"] {
  direction: ltr;
}


/*
 * حالت باز
 */
body.library-body
.library-detail-expandable.is-expanded
.library-detail-expandable__content {
  max-height: 999rem;
  overflow: visible;
}


/*
 * محوشدگی انتهای متن فقط زمانی نمایش داده می‌شود
 * که محتوا واقعاً طولانی باشد.
 */
body.library-body
.library-detail-expandable.is-overflowing:not(.is-expanded)::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 43px;
  left: 0;
  z-index: 1;

  height: 5.5em;

  pointer-events: none;

  background:
    linear-gradient(
      180deg,
      rgba(9, 8, 7, 0),
      rgba(9, 8, 7, 0.76) 52%,
      rgba(9, 8, 7, 0.98) 100%
    );
}


/*
 * دکمه نمایش بیشتر
 */
body.library-body .library-detail-expandable__button {
  position: relative;
  z-index: 2;

  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  margin-top: 12px;
  padding: 7px 14px;

  border: 1px solid rgba(244, 189, 72, 0.30);
  border-radius: 999px;

  color: var(--library-gold, #f4bd48);
  background:
    linear-gradient(
      145deg,
      rgba(244, 189, 72, 0.08),
      rgba(255, 255, 255, 0.016)
    ),
    rgba(5, 5, 5, 0.72);

  font: inherit;
  font-size: 0.68rem;
  font-weight: 950;
  line-height: 1.2;

  cursor: pointer;

  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);

  transition:
    color 220ms ease,
    border-color 220ms ease,
    background 220ms ease,
    transform 220ms ease,
    box-shadow 220ms ease;
}

body.library-body .library-detail-expandable__button:hover {
  color: #080706;
  border-color: var(--library-gold, #f4bd48);
  background:
    linear-gradient(
      135deg,
      var(--library-gold-light, #ffd36a),
      var(--library-gold, #f4bd48),
      var(--library-copper, #d8893a)
    );

  transform: translateY(-2px);

  box-shadow:
    0 16px 36px rgba(244, 189, 72, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

body.library-body
.library-detail-expandable__button:focus-visible {
  outline: 2px solid rgba(255, 211, 106, 0.86);
  outline-offset: 3px;
}


/*
 * فلش دکمه
 */
body.library-body .library-detail-expandable__icon {
  width: 7px;
  height: 7px;

  display: inline-block;

  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;

  transform:
    translateY(-2px)
    rotate(45deg);

  transition: transform 260ms ease;
}

body.library-body
.library-detail-expandable.is-expanded
.library-detail-expandable__icon {
  transform:
    translateY(2px)
    rotate(225deg);
}


/*
 * hidden باید از display دکمه قوی‌تر باشد.
 */
body.library-body
.library-detail-expandable__button[hidden] {
  display: none !important;
}


/* =========================================================
   Expandable summaries responsive
   ========================================================= */

@media (max-width: 767px) {
  body.library-body .library-detail-expandable__content {
    /*
     * در موبایل پنج خط اولیه کافی است.
     */
    max-height: 10.25em;
    font-size: 0.76rem;
    line-height: 2.05;
  }

  body.library-body
  .library-detail-expandable.is-overflowing:not(.is-expanded)::after {
    bottom: 42px;
    height: 5em;
  }
}

@media (max-width: 480px) {
  body.library-body .library-detail-expandable__content {
    max-height: 9.9em;
    font-size: 0.74rem;
    line-height: 1.98;
  }

  body.library-body .library-detail-expandable__button {
    width: 100%;
    min-height: 38px;
  }
}

/* BEGIN LIBRARY UI V2 */

/* تب‌های اصلی اکنون در بالای هیرو قرار دارند. */
body.library-body .library-hero-section .library-section-tabs {
  position: relative;
  z-index: 5;
  width: fit-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 clamp(28px, 4vw, 52px);
  padding: 6px;
  overflow-x: auto;
  direction: rtl;
  border: 1px solid rgba(244, 189, 72, 0.23);
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0%, rgba(244, 189, 72, 0.10), transparent 45%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012)),
    rgba(7, 7, 7, 0.70);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 20px 58px rgba(0, 0, 0, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  scrollbar-width: thin;
}

body.library-body .library-section-tab {
  min-width: 132px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: rgba(242, 236, 223, 0.72);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
  transition:
    color 200ms ease,
    border-color 200ms ease,
    background 200ms ease,
    transform 200ms ease,
    box-shadow 200ms ease;
}

body.library-body .library-section-tab small {
  min-width: 27px;
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border: 1px solid rgba(244, 189, 72, 0.16);
  border-radius: 999px;
  color: var(--library-gold);
  background: rgba(244, 189, 72, 0.07);
  font-family: var(--g-font-number, inherit);
  font-size: 0.68rem;
  font-weight: 950;
}

body.library-body .library-section-tab:hover {
  color: #fff;
  border-color: rgba(255, 211, 106, 0.25);
  background: rgba(244, 189, 72, 0.06);
  transform: translateY(-1px);
}

body.library-body .library-section-tab.is-active {
  color: #0b0906;
  border-color: rgba(255, 225, 145, 0.78);
  background:
    linear-gradient(135deg, var(--library-gold-light), var(--library-gold), var(--library-copper));
  box-shadow:
    0 14px 34px rgba(244, 189, 72, 0.20),
    inset 0 1px 0 rgba(255, 255, 255, 0.44);
}

body.library-body .library-section-tab.is-active small {
  color: #fff8e8;
  border-color: rgba(16, 12, 6, 0.14);
  background: rgba(16, 12, 6, 0.30);
}

/* تصویرهای اختصاصی هر تب */
body.library-body .library-section-artwork-svg {
  position: relative;
  z-index: 2;
  width: min(96%, 430px);
  height: auto;
  max-height: 500px;
  display: block;
  overflow: visible;
  filter:
    drop-shadow(0 28px 34px rgba(0, 0, 0, 0.58))
    drop-shadow(0 0 20px rgba(244, 189, 72, 0.10));
  animation: libraryArtworkFloat 5.8s ease-in-out infinite;
}

@keyframes libraryArtworkFloat {
  0%, 100% { transform: translateY(0) rotate(0.001deg); }
  50% { transform: translateY(-8px) rotate(0.001deg); }
}

/* فیلتر جدید: یک ردیف منظم در دسکتاپ و شکست کنترل‌شده در عرض‌های کمتر. */
body.library-body .library-filter-form {
  grid-template-columns:
    minmax(280px, 2.2fr)
    minmax(155px, 1fr)
    minmax(155px, 1fr)
    minmax(125px, 0.72fr)
    minmax(168px, 1fr)
    auto;
  gap: 13px;
  align-items: end;
  margin-bottom: 32px;
  padding: 18px;
  border-color: rgba(244, 189, 72, 0.22);
  border-radius: 25px;
  background:
    radial-gradient(circle at 100% 0%, rgba(244, 189, 72, 0.12), transparent 34%),
    radial-gradient(circle at 0% 100%, rgba(184, 115, 51, 0.06), transparent 38%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.060), rgba(255, 255, 255, 0.012)),
    rgba(5, 5, 5, 0.72);
  box-shadow:
    0 28px 76px rgba(0, 0, 0, 0.44),
    0 0 34px rgba(244, 189, 72, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.075);
}

body.library-body .library-filter-form__head {
  grid-column: 1 / -1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 2px;
  padding-bottom: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

body.library-body .library-filter-form__head > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

body.library-body .library-filter-form__head strong {
  color: var(--library-text-strong);
  font-size: 0.80rem;
  font-weight: 950;
}

body.library-body .library-filter-form__head small {
  color: var(--library-text-faint);
  font-size: 0.64rem;
  line-height: 1.7;
}

body.library-body .library-filter-form__icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  position: relative;
  display: inline-block;
  border: 1px solid rgba(255, 211, 106, 0.35);
  border-radius: 11px;
  background: rgba(244, 189, 72, 0.07);
}

body.library-body .library-filter-form__icon::before,
body.library-body .library-filter-form__icon::after {
  content: "";
  position: absolute;
  left: 50%;
  height: 2px;
  border-radius: 999px;
  background: var(--library-gold);
  transform: translateX(-50%);
}

body.library-body .library-filter-form__icon::before {
  top: 11px;
  width: 17px;
  box-shadow: 0 6px 0 var(--library-gold), 0 12px 0 var(--library-gold);
}

body.library-body .library-filter-form__icon::after {
  top: 9px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #111;
  box-shadow: 6px 6px 0 #111, -4px 12px 0 #111;
}

body.library-body .library-filter-field--search,
body.library-body .library-filter-field--main-category,
body.library-body .library-filter-field--subcategory,
body.library-body .library-filter-field--language,
body.library-body .library-filter-field--availability,
body.library-body .library-filter-actions {
  grid-column: auto;
}

body.library-body .library-filter-field {
  gap: 8px;
}

body.library-body .library-filter-field label {
  padding-inline: 2px;
  color: rgba(255, 220, 132, 0.88);
  font-size: 0.67rem;
}

body.library-body .library-filter-field input,
body.library-body .library-filter-field select {
  min-height: 50px;
  border-color: rgba(255, 255, 255, 0.11);
  border-radius: 14px;
  background-color: rgba(8, 8, 8, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

body.library-body .library-filter-field select {
  padding: 0 13px 0 42px;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M2 2l5 5 5-5' fill='none' stroke='%23FFD36A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
    linear-gradient(145deg, rgba(255, 255, 255, 0.050), rgba(255, 255, 255, 0.012));
  background-position: left 16px center, center;
  background-size: 14px 9px, 100% 100%;
  background-repeat: no-repeat;
}

body.library-body .library-filter-field input:hover,
body.library-body .library-filter-field select:hover {
  border-color: rgba(244, 189, 72, 0.30);
}

body.library-body .library-filter-field select:disabled {
  cursor: not-allowed;
  opacity: 0.50;
  filter: saturate(0.7);
}

body.library-body .library-filter-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(106px, 1fr));
  gap: 8px;
  justify-content: stretch;
}

body.library-body .library-filter-submit,
body.library-body .library-filter-reset {
  min-width: 0;
  min-height: 50px;
  padding-inline: 16px;
  border-radius: 14px;
}

body.library-body .library-filter-reset {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.010)),
    rgba(244, 189, 72, 0.035);
}

@media (max-width: 1199px) {
  body.library-body .library-filter-form {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  body.library-body .library-filter-form__head {
    grid-column: 1 / -1;
  }

  body.library-body .library-filter-field--search { grid-column: span 6; }
  body.library-body .library-filter-field--main-category { grid-column: span 3; }
  body.library-body .library-filter-field--subcategory { grid-column: span 3; }
  body.library-body .library-filter-field--language { grid-column: span 3; }
  body.library-body .library-filter-field--availability { grid-column: span 5; }
  body.library-body .library-filter-actions { grid-column: span 4; }
}

@media (max-width: 900px) {
  body.library-body .library-hero-section .library-section-tabs {
    margin-bottom: 32px;
  }

  body.library-body .library-filter-field--search { grid-column: 1 / -1; }
  body.library-body .library-filter-field--main-category,
  body.library-body .library-filter-field--subcategory { grid-column: span 6; }
  body.library-body .library-filter-field--language { grid-column: span 4; }
  body.library-body .library-filter-field--availability { grid-column: span 8; }
  body.library-body .library-filter-actions { grid-column: 1 / -1; }
}

@media (max-width: 767px) {
  body.library-body .library-hero-section .library-section-tabs {
    width: 100%;
    margin-bottom: 26px;
    justify-content: flex-start;
  }

  body.library-body .library-section-tab {
    min-width: 118px;
    flex: 0 0 auto;
  }

  body.library-body .library-filter-form {
    grid-template-columns: 1fr;
    gap: 11px;
    padding: 14px;
  }

  body.library-body .library-filter-form__head,
  body.library-body .library-filter-field--search,
  body.library-body .library-filter-field--main-category,
  body.library-body .library-filter-field--subcategory,
  body.library-body .library-filter-field--language,
  body.library-body .library-filter-field--availability,
  body.library-body .library-filter-actions {
    grid-column: auto;
  }

  body.library-body .library-filter-form__head small {
    display: none;
  }

  body.library-body .library-filter-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.library-body .library-section-artwork-svg {
    animation: none;
  }
}

/* END LIBRARY UI V2 */

/* BEGIN LIBRARY UI V3 */

/* تب‌ها دقیقاً در مرکز هیرو و با فرم کپسولی هماهنگ با دکمه‌های سایت. */
body.library-body .library-hero-section .library-section-tabs {
  margin-right: auto;
  margin-left: auto;
  border-radius: 999px;
  padding: 7px;
}

body.library-body .library-section-tab {
  min-height: 52px;
  border-radius: 999px;
  padding-inline: 20px;
}

body.library-body .library-section-tab small {
  min-width: 29px;
  min-height: 29px;
}

/* دکمه‌های فیلتر نیز فرم گرد و هماهنگ با دکمه‌های اصلی سایت دارند. */
body.library-body .library-filter-submit,
body.library-body .library-filter-reset {
  border-radius: 999px;
}

/* متن‌های چندخطی داخل باکس اطلاعات، برای فارسی و انگلیسی Justify می‌شوند. */
body.library-body .library-resource-meta__row > span:not(.ltr):not(.library-ltr) {
  text-align: justify;
  text-align-last: start;
  text-justify: inter-word;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
  hyphens: auto;
}

body.library-body .library-resource-meta__row > span[dir="auto"] {
  text-align: justify;
  text-align-last: start;
}

/* عمق بیشتر برای تصویرهای مقاله و گزارش. */
body.library-body .library-reports-artwork,
body.library-body .library-articles-artwork {
  width: min(98%, 450px);
  transform-style: preserve-3d;
  perspective: 900px;
  filter:
    drop-shadow(0 38px 32px rgba(0, 0, 0, 0.72))
    drop-shadow(0 0 26px rgba(244, 189, 72, 0.13));
}

body.library-body .library-hero-section[data-library-section="reports"]
.library-hero-artwork,
body.library-body .library-hero-section[data-library-section="articles"]
.library-hero-artwork {
  background:
    radial-gradient(circle at 48% 42%, rgba(244, 189, 72, 0.19), transparent 47%),
    radial-gradient(circle at 78% 16%, rgba(184, 115, 51, 0.15), transparent 31%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.060), rgba(255, 255, 255, 0.008)),
    rgba(0, 0, 0, 0.30);
}

@media (max-width: 767px) {
  body.library-body .library-hero-section .library-section-tabs {
    width: fit-content;
    max-width: 100%;
    justify-content: flex-start;
  }

  body.library-body .library-section-tab {
    min-width: 112px;
    min-height: 48px;
    padding-inline: 15px;
  }
}

/* END LIBRARY UI V3 */

/* BEGIN REPORT PAPER TO FOLDER ANIMATION */

body.library-body .library-reports-artwork {
  overflow: visible;
}

body.library-body .library-report-transfer {
  pointer-events: none;
}

body.library-body .library-report-folder-back,
body.library-body .library-report-folder-front {
  transform-box: fill-box;
  transform-origin: center;
  animation: libraryReportFolderBreath 5.4s ease-in-out infinite;
}

body.library-body .library-report-moving-paper {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  will-change: transform, opacity;
  animation: libraryReportPaperTransfer 5.4s cubic-bezier(0.42, 0, 0.2, 1) infinite;
}

@keyframes libraryReportPaperTransfer {
  0%, 7% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.94);
  }

  12% {
    opacity: 1;
  }

  /* خروج برگه از داخل جلد گزارش */
  30% {
    opacity: 1;
    transform: translate3d(-4px, -112px, 0) rotate(-4deg) scale(1);
  }

  /* حرکت برگه در فضای بیرون به سمت پوشه */
  55% {
    opacity: 1;
    transform: translate3d(-93px, -48px, 0) rotate(-13deg) scale(0.88);
  }

  73% {
    opacity: 1;
    transform: translate3d(-119px, 83px, 0) rotate(-15deg) scale(0.72);
  }

  /* ورود به داخل پوشه و محو شدن پشت لبه جلویی */
  86% {
    opacity: 0.96;
    transform: translate3d(-126px, 150px, 0) rotate(-15deg) scale(0.64);
  }

  92%, 100% {
    opacity: 0;
    transform: translate3d(-126px, 176px, 0) rotate(-15deg) scale(0.60);
  }
}

@keyframes libraryReportFolderBreath {
  0%, 100% {
    transform: translateY(0) rotate(0.001deg);
  }

  50% {
    transform: translateY(-3px) rotate(0.001deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.library-body .library-report-moving-paper,
  body.library-body .library-report-folder-back,
  body.library-body .library-report-folder-front {
    animation: none;
  }

  body.library-body .library-report-moving-paper {
    opacity: 1;
    transform: translate3d(-119px, 83px, 0) rotate(-15deg) scale(0.72);
  }
}

/* END REPORT PAPER TO FOLDER ANIMATION */

/* BEGIN ARTICLES SCAN ANIMATION */
body.library-body .library-articles-artwork {
  overflow: visible;
}

body.library-body .library-article-document,
body.library-body .library-article-back-sheet,
body.library-body .library-article-magnifier,
body.library-body .library-article-bookmark,
body.library-body .library-article-chart-point,
body.library-body .library-article-ground-shadow {
  transform-box: fill-box;
  transform-origin: center;
}

body.library-body .library-article-document {
  animation: libraryArticleDocumentBreath 6.2s ease-in-out infinite;
}

body.library-body .library-article-back-sheet--teal {
  animation: libraryArticleBackTeal 6.2s ease-in-out infinite;
}

body.library-body .library-article-back-sheet--red {
  animation: libraryArticleBackRed 6.2s ease-in-out infinite;
}

body.library-body .library-article-magnifier {
  animation: libraryArticleMagnifierScan 6.2s cubic-bezier(0.45, 0, 0.2, 1) infinite;
  will-change: transform;
}

body.library-body .library-article-scan-beam {
  opacity: 0;
  animation: libraryArticleScanBeam 6.2s ease-in-out infinite;
  will-change: transform, opacity;
}

body.library-body .library-article-chart-line {
  stroke-dasharray: 94;
  stroke-dashoffset: 94;
  animation: libraryArticleChartDraw 6.2s ease-in-out infinite;
}

body.library-body .library-article-chart-point {
  opacity: 0;
  animation: libraryArticlePointPulse 6.2s ease-in-out infinite;
}

body.library-body .library-article-chart-point--two {
  animation-delay: 0.16s;
}

body.library-body .library-article-checkmark {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: libraryArticleCheckDraw 6.2s ease-in-out infinite;
}

body.library-body .library-article-lens-glow {
  animation: libraryArticleLensGlow 6.2s ease-in-out infinite;
}

body.library-body .library-article-bookmark {
  animation: libraryArticleBookmark 6.2s ease-in-out infinite;
}

body.library-body .library-article-ground-shadow {
  animation: libraryArticleShadow 6.2s ease-in-out infinite;
}

@keyframes libraryArticleMagnifierScan {
  0%, 8% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  20% {
    transform: translate(-28px, -54px) rotate(-9deg) scale(0.98);
  }
  38% {
    transform: translate(-72px, -105px) rotate(-14deg) scale(0.94);
  }
  54% {
    transform: translate(-42px, -164px) rotate(8deg) scale(0.91);
  }
  68% {
    transform: translate(3px, -116px) rotate(13deg) scale(0.95);
  }
  82%, 100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes libraryArticleScanBeam {
  0%, 13%, 84%, 100% {
    opacity: 0;
    transform: translateY(-24px) rotate(-10deg);
  }
  20% {
    opacity: 0.18;
  }
  34% {
    opacity: 0.78;
    transform: translateY(72px) rotate(-10deg);
  }
  55% {
    opacity: 0.56;
    transform: translateY(196px) rotate(-10deg);
  }
  72% {
    opacity: 0;
    transform: translateY(278px) rotate(-10deg);
  }
}

@keyframes libraryArticleChartDraw {
  0%, 26% { stroke-dashoffset: 94; }
  48%, 76% { stroke-dashoffset: 0; }
  92%, 100% { stroke-dashoffset: 94; }
}

@keyframes libraryArticlePointPulse {
  0%, 34%, 86%, 100% {
    opacity: 0;
    transform: scale(0.5);
  }
  48%, 72% {
    opacity: 1;
    transform: scale(1.35);
  }
  58% {
    transform: scale(0.9);
  }
}

@keyframes libraryArticleCheckDraw {
  0%, 48% { stroke-dashoffset: 48; opacity: 0.25; }
  62%, 82% { stroke-dashoffset: 0; opacity: 1; }
  96%, 100% { stroke-dashoffset: 48; opacity: 0.25; }
}

@keyframes libraryArticleLensGlow {
  0%, 42%, 92%, 100% {
    filter: none;
    fill-opacity: 0.5;
  }
  58%, 78% {
    filter: url(#a4Glow);
    fill-opacity: 0.78;
  }
}

@keyframes libraryArticleDocumentBreath {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  34% { transform: translateY(-2px) rotate(-0.35deg); }
  64% { transform: translateY(1px) rotate(0.2deg); }
}

@keyframes libraryArticleBackTeal {
  0%, 100% { transform: translate(0, 0); }
  45% { transform: translate(6px, -4px); }
}

@keyframes libraryArticleBackRed {
  0%, 100% { transform: translate(0, 0); }
  45% { transform: translate(-5px, 3px); }
}

@keyframes libraryArticleBookmark {
  0%, 42%, 100% { transform: translateY(0); }
  56% { transform: translateY(-8px); }
  70% { transform: translateY(-2px); }
}

@keyframes libraryArticleShadow {
  0%, 100% { transform: scaleX(1); opacity: 0.65; }
  48% { transform: scaleX(0.9); opacity: 0.52; }
}

@media (prefers-reduced-motion: reduce) {
  body.library-body .library-article-document,
  body.library-body .library-article-back-sheet,
  body.library-body .library-article-magnifier,
  body.library-body .library-article-scan-beam,
  body.library-body .library-article-chart-line,
  body.library-body .library-article-chart-point,
  body.library-body .library-article-checkmark,
  body.library-body .library-article-lens-glow,
  body.library-body .library-article-bookmark,
  body.library-body .library-article-ground-shadow {
    animation: none !important;
  }

  body.library-body .library-article-chart-line,
  body.library-body .library-article-checkmark {
    stroke-dashoffset: 0;
  }

  body.library-body .library-article-chart-point {
    opacity: 1;
  }
}
/* END ARTICLES SCAN ANIMATION */

/* BEGIN LIBRARY BOOKSHELF PICK ANIMATION */
body.library-body .library-bookshelf-svg {
  width: min(98%, 470px);
  max-height: 520px;
  overflow: visible;
}

body.library-body .library-bookshelf-scene {
  transform-box: fill-box;
  transform-origin: center;
  animation: libraryBookshelfBreathe 6.8s ease-in-out infinite;
}

body.library-body .library-shelf-row {
  transform-box: fill-box;
  transform-origin: center bottom;
}

body.library-body .library-shelf-row--one {
  animation: libraryShelfBooksLean 7s ease-in-out infinite;
}

body.library-body .library-shelf-row--two {
  animation: libraryShelfBooksLean 7s ease-in-out 1.2s infinite reverse;
}

body.library-body .library-shelf-row--three {
  animation: libraryShelfBooksLean 7s ease-in-out 2.2s infinite;
}

body.library-body .library-reading-desk {
  transform-box: fill-box;
  transform-origin: center;
  animation: libraryDeskFloat 5.6s ease-in-out infinite;
}

body.library-body .library-desk-stack {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: libraryDeskStackSettle 5.2s ease-in-out infinite;
}

body.library-body .library-moving-book,
body.library-body .library-book-grabber {
  transform-box: view-box;
  transform-origin: center;
  will-change: transform, opacity;
}

body.library-body .library-moving-book--one {
  animation: libraryPickBookOne 10s cubic-bezier(.62, 0, .22, 1) infinite;
}

body.library-body .library-book-grabber--one {
  animation: libraryGrabberOne 10s cubic-bezier(.62, 0, .22, 1) infinite;
}

body.library-body .library-moving-book--two {
  animation: libraryPickBookTwo 10s cubic-bezier(.62, 0, .22, 1) 5s infinite;
}

body.library-body .library-book-grabber--two {
  animation: libraryGrabberTwo 10s cubic-bezier(.62, 0, .22, 1) 5s infinite;
}

body.library-body .library-book-flight-path {
  stroke-dashoffset: 120;
  opacity: 0;
}

body.library-body .library-book-flight-path--one {
  animation: libraryFlightTrail 10s ease-in-out infinite;
}

body.library-body .library-book-flight-path--two {
  animation: libraryFlightTrail 10s ease-in-out 5s infinite;
}

body.library-body .library-bookshelf-sparkles > * {
  transform-box: fill-box;
  transform-origin: center;
  animation: libraryShelfSparkle 2.8s ease-in-out infinite;
}

body.library-body .library-bookshelf-sparkles > *:nth-child(2) { animation-delay: .7s; }
body.library-body .library-bookshelf-sparkles > *:nth-child(3) { animation-delay: 1.4s; }
body.library-body .library-bookshelf-sparkles > *:nth-child(4) { animation-delay: 2.1s; }

@keyframes libraryBookshelfBreathe {
  0%, 100% { transform: translateY(0) rotate(.001deg); }
  50% { transform: translateY(-5px) rotate(.001deg); }
}

@keyframes libraryShelfBooksLean {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  50% { transform: rotate(.7deg) translateY(-1px); }
}

@keyframes libraryDeskFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes libraryDeskStackSettle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  46% { transform: translateY(-1px) rotate(.3deg); }
  52% { transform: translateY(2px) rotate(-.3deg); }
  58% { transform: translateY(0) rotate(0deg); }
}

@keyframes libraryPickBookOne {
  0%, 8% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  13% { transform: translate(4px, -12px) rotate(-5deg) scale(1.02); }
  26% { transform: translate(92px, -32px) rotate(-13deg) scale(1.06); }
  45% { opacity: 1; transform: translate(150px, 142px) rotate(76deg) scale(1.08); }
  57% { transform: translate(92px, 252px) rotate(87deg) scale(1.03); }
  66%, 78% { opacity: 1; transform: translate(84px, 265px) rotate(90deg) scale(1); }
  86%, 100% { opacity: 0; transform: translate(84px, 265px) rotate(90deg) scale(1); }
}

@keyframes libraryGrabberOne {
  0%, 7% { opacity: 0; transform: translate(0, 0) scale(.75) rotate(0deg); }
  12% { opacity: .95; transform: translate(4px, -12px) scale(1) rotate(18deg); }
  26% { opacity: .9; transform: translate(92px, -32px) scale(1.08) rotate(92deg); }
  45% { opacity: .72; transform: translate(150px, 142px) scale(.95) rotate(185deg); }
  57% { opacity: .4; transform: translate(92px, 252px) scale(.82) rotate(260deg); }
  65%, 100% { opacity: 0; transform: translate(84px, 265px) scale(.65) rotate(330deg); }
}

@keyframes libraryPickBookTwo {
  0%, 8% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  13% { transform: translate(6px, -10px) rotate(5deg) scale(1.02); }
  28% { transform: translate(76px, -30px) rotate(16deg) scale(1.06); }
  46% { opacity: 1; transform: translate(118px, 54px) rotate(76deg) scale(1.08); }
  58% { transform: translate(54px, 102px) rotate(88deg) scale(1.03); }
  67%, 78% { opacity: 1; transform: translate(48px, 111px) rotate(90deg) scale(1); }
  86%, 100% { opacity: 0; transform: translate(48px, 111px) rotate(90deg) scale(1); }
}

@keyframes libraryGrabberTwo {
  0%, 7% { opacity: 0; transform: translate(0, 0) scale(.75) rotate(0deg); }
  12% { opacity: .95; transform: translate(6px, -10px) scale(1) rotate(-15deg); }
  28% { opacity: .9; transform: translate(76px, -30px) scale(1.06) rotate(-90deg); }
  46% { opacity: .7; transform: translate(118px, 54px) scale(.94) rotate(-180deg); }
  58% { opacity: .38; transform: translate(54px, 102px) scale(.82) rotate(-260deg); }
  65%, 100% { opacity: 0; transform: translate(48px, 111px) scale(.65) rotate(-330deg); }
}

@keyframes libraryFlightTrail {
  0%, 8% { opacity: 0; stroke-dashoffset: 120; }
  18% { opacity: .18; }
  45% { opacity: .72; stroke-dashoffset: 0; }
  62% { opacity: .18; stroke-dashoffset: -70; }
  70%, 100% { opacity: 0; stroke-dashoffset: -120; }
}

@keyframes libraryShelfSparkle {
  0%, 100% { opacity: .25; transform: scale(.75) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.18) rotate(90deg); }
}

@media (max-width: 767px) {
  body.library-body .library-bookshelf-svg {
    width: min(96%, 410px);
    max-height: 450px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.library-body .library-bookshelf-scene,
  body.library-body .library-shelf-row,
  body.library-body .library-reading-desk,
  body.library-body .library-desk-stack,
  body.library-body .library-moving-book,
  body.library-body .library-book-grabber,
  body.library-body .library-book-flight-path,
  body.library-body .library-bookshelf-sparkles > * {
    animation: none !important;
  }

  body.library-body .library-book-grabber,
  body.library-body .library-book-flight-path {
    display: none;
  }
}
/* END LIBRARY BOOKSHELF PICK ANIMATION */

/* BEGIN UNIFIED LIBRARY ANIMATIONS V4 */

body.library-body .library-detail-library-svg,
body.library-body .library-reports-library-svg,
body.library-body .library-articles-library-svg {
  width: min(98%, 470px);
  max-height: 520px;
  overflow: visible;
}

body.library-body .library-detail-visual:has(.library-detail-library-svg) > svg:not(.library-detail-library-svg),
body.library-body .library-detail-visual:has(.library-detail-library-svg) > .library-detail-fallback-book {
  display: none;
}

/* ---------- Detail: shelf selection and page turning ---------- */
body.library-body .detail-library-shelf,
body.library-body .reports-archive-shelf,
body.library-body .articles-journal-shelf {
  transform-box: fill-box;
  transform-origin: center;
  animation: unifiedLibraryBreathe 6.8s ease-in-out infinite;
}

body.library-body .detail-shelf-books,
body.library-body .reports-binders,
body.library-body .articles-journals {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: unifiedShelfLean 7.2s ease-in-out infinite;
}

body.library-body .detail-shelf-books--bottom,
body.library-body .reports-binders--top,
body.library-body .articles-journals--bottom {
  animation-delay: 1.1s;
  animation-direction: reverse;
}

body.library-body .detail-selected-book,
body.library-body .detail-selection-ring,
body.library-body .reports-moving-folder,
body.library-body .articles-selected-journal {
  transform-box: view-box;
  transform-origin: center;
  will-change: transform, opacity;
}

body.library-body .detail-selected-book {
  animation: detailBookSelectOpen 11s cubic-bezier(.62, 0, .22, 1) infinite;
}

body.library-body .detail-book-closed {
  transform-box: fill-box;
  transform-origin: center;
  animation: detailClosedBookFade 11s ease-in-out infinite;
}

body.library-body .detail-open-book {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: detailOpenBookReveal 11s ease-in-out infinite;
}

body.library-body .detail-selection-ring {
  animation: detailSelectionRing 11s ease-in-out infinite;
}

body.library-body .detail-selection-trail,
body.library-body .reports-folder-trail,
body.library-body .articles-journal-trail {
  stroke-dashoffset: 150;
  animation: unifiedTravelTrail 11s ease-in-out infinite;
}

body.library-body .detail-page-flip {
  transform-box: fill-box;
  transform-origin: left center;
  opacity: 0;
}

body.library-body .detail-page-flip--one { animation: detailPageTurn 11s ease-in-out 5.7s infinite; }
body.library-body .detail-page-flip--two { animation: detailPageTurn 11s ease-in-out 6.35s infinite; }
body.library-body .detail-page-flip--three { animation: detailPageTurn 11s ease-in-out 7s infinite; }

body.library-body .detail-library-sparkles > *,
body.library-body .reports-sparkles > *,
body.library-body .articles-sparkles > * {
  transform-box: fill-box;
  transform-origin: center;
  animation: unifiedSparkle 2.8s ease-in-out infinite;
}

body.library-body .detail-library-sparkles > *:nth-child(2),
body.library-body .reports-sparkles > *:nth-child(2),
body.library-body .articles-sparkles > *:nth-child(2) { animation-delay: .8s; }

body.library-body .detail-library-sparkles > *:nth-child(3),
body.library-body .reports-sparkles > *:nth-child(3),
body.library-body .articles-sparkles > *:nth-child(3) { animation-delay: 1.6s; }

/* ---------- Reports: archive folder and sheets ---------- */
body.library-body .reports-moving-folder {
  animation: reportsFolderSelect 11s cubic-bezier(.62, 0, .22, 1) infinite;
}

body.library-body .reports-paper-stack,
body.library-body .reports-open-folder {
  transform-box: fill-box;
  transform-origin: center bottom;
}

body.library-body .reports-open-folder {
  animation: reportsFolderSettle 5.6s ease-in-out infinite;
}

body.library-body .reports-paper--back {
  animation: reportsPaperArchive 11s cubic-bezier(.62, 0, .22, 1) 2.8s infinite;
}

body.library-body .reports-paper--front {
  animation: reportsPaperArchive 11s cubic-bezier(.62, 0, .22, 1) 3.45s infinite;
}

body.library-body .reports-folder-front {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: reportsFolderFront 11s ease-in-out infinite;
}

/* ---------- Articles: journal selection, opening and scanning ---------- */
body.library-body .articles-selected-journal {
  animation: articlesJournalSelect 11s cubic-bezier(.62, 0, .22, 1) infinite;
}

body.library-body .articles-open-journal {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: articlesJournalOpen 11s ease-in-out infinite;
}

body.library-body .articles-magnifier {
  transform-box: fill-box;
  transform-origin: center;
  animation: articlesMagnifierScan 11s cubic-bezier(.45, 0, .25, 1) infinite;
}

body.library-body .articles-scan-beam {
  transform-box: fill-box;
  transform-origin: center;
  animation: articlesScanBeam 11s ease-in-out infinite;
}

body.library-body .articles-chart-line {
  stroke-dasharray: 170;
  stroke-dashoffset: 170;
  animation: articlesChartDraw 11s ease-in-out infinite;
}

body.library-body .articles-chart-points > * {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: articlesPointPulse 11s ease-in-out infinite;
}

body.library-body .articles-chart-points > *:nth-child(2) { animation-delay: .2s; }
body.library-body .articles-chart-points > *:nth-child(3) { animation-delay: .4s; }
body.library-body .articles-chart-points > *:nth-child(4) { animation-delay: .6s; }

body.library-body .articles-check {
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: articlesCheckDraw 11s ease-in-out infinite;
}

@keyframes unifiedLibraryBreathe {
  0%, 100% { transform: translateY(0) rotate(.001deg); }
  50% { transform: translateY(-5px) rotate(.001deg); }
}

@keyframes unifiedShelfLean {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  50% { transform: rotate(.7deg) translateY(-1px); }
}

@keyframes unifiedSparkle {
  0%, 100% { opacity: .25; transform: scale(.75) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.18) rotate(90deg); }
}

@keyframes unifiedTravelTrail {
  0%, 7% { opacity: 0; stroke-dashoffset: 150; }
  18% { opacity: .2; }
  44% { opacity: .72; stroke-dashoffset: 0; }
  62% { opacity: .16; stroke-dashoffset: -80; }
  70%, 100% { opacity: 0; stroke-dashoffset: -150; }
}

@keyframes detailBookSelectOpen {
  0%, 8% { transform: translate(0, 0) rotate(0deg) scale(1); }
  14% { transform: translate(8px, -16px) rotate(-6deg) scale(1.03); }
  30% { transform: translate(118px, -28px) rotate(-13deg) scale(1.08); }
  45% { transform: translate(76px, 126px) rotate(74deg) scale(1.1); }
  56% { transform: translate(25px, 175px) rotate(88deg) scale(1.04); }
  63%, 82% { transform: translate(20px, 177px) rotate(90deg) scale(1); }
  90%, 100% { transform: translate(20px, 177px) rotate(90deg) scale(1); }
}

@keyframes detailClosedBookFade {
  0%, 47% { opacity: 1; }
  55%, 100% { opacity: 0; }
}

@keyframes detailOpenBookReveal {
  0%, 47% { opacity: 0; transform: scale(.82) translateY(22px); }
  57% { opacity: 1; transform: scale(1.03) translateY(-3px); }
  64%, 92% { opacity: 1; transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(.96) translateY(8px); }
}

@keyframes detailSelectionRing {
  0%, 7% { opacity: 0; transform: scale(.75) rotate(0deg); }
  13% { opacity: .95; transform: scale(1) rotate(18deg); }
  30% { opacity: .8; transform: translate(118px, -28px) scale(1.1) rotate(105deg); }
  48% { opacity: .35; transform: translate(76px, 126px) scale(.86) rotate(210deg); }
  58%, 100% { opacity: 0; transform: translate(25px, 175px) scale(.65) rotate(320deg); }
}

@keyframes detailPageTurn {
  0%, 50% { opacity: 0; transform: perspective(600px) rotateY(0deg) translateX(0); }
  54% { opacity: 1; }
  62% { opacity: .92; transform: perspective(600px) rotateY(-150deg) translateX(-6px); }
  68%, 100% { opacity: 0; transform: perspective(600px) rotateY(-175deg) translateX(-12px); }
}

@keyframes reportsFolderSelect {
  0%, 8% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  14% { transform: translate(5px, -14px) rotate(-5deg) scale(1.03); }
  31% { transform: translate(120px, -24px) rotate(-12deg) scale(1.08); }
  48% { transform: translate(122px, 128px) rotate(5deg) scale(1.05); }
  60%, 78% { transform: translate(30px, 230px) rotate(-4deg) scale(.88); opacity: .4; }
  86%, 100% { transform: translate(30px, 230px) rotate(-4deg) scale(.8); opacity: 0; }
}

@keyframes reportsPaperArchive {
  0%, 28% { opacity: 0; transform: translate(0, -42px) rotate(-5deg) scale(.9); }
  38% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  56% { opacity: 1; transform: translate(-62px, 62px) rotate(-8deg) scale(.94); }
  70% { opacity: .95; transform: translate(-100px, 112px) rotate(-9deg) scale(.82); }
  78%, 100% { opacity: 0; transform: translate(-116px, 132px) rotate(-9deg) scale(.74); }
}

@keyframes reportsFolderSettle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(.4deg); }
}

@keyframes reportsFolderFront {
  0%, 42% { transform: rotateX(0deg) translateY(0); }
  56% { transform: perspective(500px) rotateX(-16deg) translateY(3px); }
  73% { transform: perspective(500px) rotateX(7deg) translateY(-2px); }
  84%, 100% { transform: rotateX(0deg) translateY(0); }
}

@keyframes articlesJournalSelect {
  0%, 8% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  14% { transform: translate(6px, -14px) rotate(-5deg) scale(1.03); }
  31% { transform: translate(112px, -26px) rotate(-13deg) scale(1.08); }
  48% { transform: translate(62px, 123px) rotate(76deg) scale(1.08); }
  58% { opacity: .2; transform: translate(22px, 170px) rotate(88deg) scale(.96); }
  64%, 100% { opacity: 0; transform: translate(22px, 170px) rotate(90deg) scale(.9); }
}

@keyframes articlesJournalOpen {
  0%, 45% { opacity: 0; transform: scale(.82) translateY(22px); }
  56% { opacity: 1; transform: scale(1.03) translateY(-3px); }
  64%, 92% { opacity: 1; transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(.96) translateY(8px); }
}

@keyframes articlesMagnifierScan {
  0%, 48% { opacity: 0; transform: translate(70px, -82px) scale(.72) rotate(-12deg); }
  56% { opacity: 1; transform: translate(35px, -35px) scale(.9) rotate(-6deg); }
  67% { opacity: 1; transform: translate(-88px, -42px) scale(1) rotate(4deg); }
  78% { opacity: 1; transform: translate(-20px, 18px) scale(1.04) rotate(-3deg); }
  89% { opacity: .9; transform: translate(35px, -4px) scale(.96) rotate(3deg); }
  96%, 100% { opacity: 0; transform: translate(70px, -82px) scale(.72) rotate(-12deg); }
}

@keyframes articlesScanBeam {
  0%, 54% { opacity: 0; transform: translateY(-18px) scaleX(.5); }
  60% { opacity: .42; transform: translateY(0) scaleX(1); }
  76% { opacity: .22; transform: translateY(92px) scaleX(.94); }
  84%, 100% { opacity: 0; transform: translateY(112px) scaleX(.7); }
}

@keyframes articlesChartDraw {
  0%, 61% { stroke-dashoffset: 170; opacity: 0; }
  67% { opacity: 1; }
  80%, 94% { stroke-dashoffset: 0; opacity: 1; }
  100% { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes articlesPointPulse {
  0%, 66% { opacity: 0; transform: scale(.45); }
  72% { opacity: 1; transform: scale(1.25); }
  78%, 94% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.7); }
}

@keyframes articlesCheckDraw {
  0%, 76% { stroke-dashoffset: 60; opacity: 0; }
  82% { opacity: 1; }
  91%, 96% { stroke-dashoffset: 0; opacity: 1; }
  100% { opacity: 0; stroke-dashoffset: 0; }
}

@media (max-width: 767px) {
  body.library-body .library-detail-library-svg,
  body.library-body .library-reports-library-svg,
  body.library-body .library-articles-library-svg {
    width: min(96%, 410px);
    max-height: 450px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.library-body .detail-library-shelf,
  body.library-body .detail-shelf-books,
  body.library-body .detail-selected-book,
  body.library-body .detail-selection-ring,
  body.library-body .detail-selection-trail,
  body.library-body .detail-open-book,
  body.library-body .detail-page-flip,
  body.library-body .reports-archive-shelf,
  body.library-body .reports-binders,
  body.library-body .reports-moving-folder,
  body.library-body .reports-paper,
  body.library-body .reports-open-folder,
  body.library-body .reports-folder-front,
  body.library-body .reports-folder-trail,
  body.library-body .articles-journal-shelf,
  body.library-body .articles-journals,
  body.library-body .articles-selected-journal,
  body.library-body .articles-open-journal,
  body.library-body .articles-magnifier,
  body.library-body .articles-scan-beam,
  body.library-body .articles-chart-line,
  body.library-body .articles-chart-points > *,
  body.library-body .articles-check,
  body.library-body .articles-journal-trail,
  body.library-body .detail-library-sparkles > *,
  body.library-body .reports-sparkles > *,
  body.library-body .articles-sparkles > * {
    animation: none !important;
  }

  body.library-body .detail-selection-ring,
  body.library-body .detail-selection-trail,
  body.library-body .reports-folder-trail,
  body.library-body .articles-journal-trail,
  body.library-body .articles-scan-beam {
    display: none;
  }

  body.library-body .detail-book-closed,
  body.library-body .reports-moving-folder,
  body.library-body .articles-selected-journal {
    opacity: 0;
  }

  body.library-body .detail-open-book,
  body.library-body .articles-open-journal {
    opacity: 1;
  }
}

/* END UNIFIED LIBRARY ANIMATIONS V4 */

/* BEGIN DETAIL BOOKSHELF UNIFY V5 */

/*
 * صفحه جزئیات اکنون از همان هندسه، چوب، نور و رنگ‌بندی
 * قفسه صفحه اصلی کتابخانه استفاده می‌کند.
 */
body.library-body .library-detail-bookshelf-v5 {
  width: min(98%, 470px);
  max-height: 520px;
  overflow: visible;
}

body.library-body .detail-library-shelf-v5 {
  transform-box: fill-box;
  transform-origin: center;
  animation: detailV5ShelfBreathe 6.8s ease-in-out infinite;
}

body.library-body .detail-reading-desk-v5 {
  transform-box: fill-box;
  transform-origin: center;
  animation: detailV5DeskFloat 5.8s ease-in-out infinite;
}

/*
 * کتاب بسته تنها عنصری است که از قفسه خارج می‌شود.
 * کتاب باز یک گروه مستقل است؛ بنابراین دیگر چرخش 90 درجه
 * کتاب متحرک را به ارث نمی‌برد و وارونه نمایش داده نمی‌شود.
 */
body.library-body .detail-selected-book-v5 {
  transform-box: view-box;
  transform-origin: center;
  animation: detailV5BookPick 11s cubic-bezier(.62, 0, .22, 1) infinite;
}

body.library-body .detail-selected-book-v5 .detail-book-closed {
  transform-box: fill-box;
  transform-origin: center;
  animation: detailV5ClosedBookVisibility 11s ease-in-out infinite;
}

body.library-body .detail-open-book-v5 {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: detailV5OpenBookReveal 11s cubic-bezier(.2, .8, .2, 1) infinite;
}

body.library-body .detail-selection-ring-v5 {
  transform-box: view-box;
  transform-origin: center;
  animation: detailV5SelectionRing 11s ease-in-out infinite;
}

body.library-body .detail-selection-trail-v5 {
  stroke-dashoffset: 150;
  animation: detailV5TravelTrail 11s ease-in-out infinite;
}

/*
 * صفحه از سمت راست شروع می‌شود، عطف در لبه چپ صفحه است
 * و صفحه به سمت چپ کتاب می‌چرخد.
 */
body.library-body .detail-open-book-v5 .detail-page-flip {
  transform-box: fill-box;
  transform-origin: left center;
  opacity: 0;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

body.library-body .detail-open-book-v5 .detail-page-flip--one {
  animation: detailV5PageTurn 11s cubic-bezier(.48, 0, .22, 1) 5.65s infinite;
}

body.library-body .detail-open-book-v5 .detail-page-flip--two {
  animation: detailV5PageTurn 11s cubic-bezier(.48, 0, .22, 1) 6.35s infinite;
}

body.library-body .detail-open-book-v5 .detail-page-flip--three {
  animation: detailV5PageTurn 11s cubic-bezier(.48, 0, .22, 1) 7.05s infinite;
}

@keyframes detailV5ShelfBreathe {
  0%, 100% {
    transform: translateY(0) rotate(.001deg);
  }

  50% {
    transform: translateY(-5px) rotate(.001deg);
  }
}

@keyframes detailV5DeskFloat {
  0%, 100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }
}

@keyframes detailV5BookPick {
  0%, 8% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  14% {
    transform: translate(7px, -15px) rotate(-5deg) scale(1.03);
  }

  30% {
    transform: translate(112px, -29px) rotate(-13deg) scale(1.08);
  }

  45% {
    transform: translate(133px, 105px) rotate(55deg) scale(1.08);
  }

  55% {
    opacity: 1;
    transform: translate(105px, 211px) rotate(88deg) scale(1.02);
  }

  61% {
    opacity: 0;
    transform: translate(105px, 211px) rotate(90deg) scale(.96);
  }

  100% {
    opacity: 0;
    transform: translate(105px, 211px) rotate(90deg) scale(.96);
  }
}

@keyframes detailV5ClosedBookVisibility {
  0%, 52% {
    opacity: 1;
  }

  59%, 100% {
    opacity: 0;
  }
}

@keyframes detailV5OpenBookReveal {
  0%, 48% {
    opacity: 0;
    transform: translateY(24px) scale(.76) rotateX(18deg);
  }

  57% {
    opacity: 1;
    transform: translateY(-4px) scale(1.04) rotateX(0deg);
  }

  64%, 91% {
    opacity: 1;
    transform: translateY(0) scale(1) rotateX(0deg);
  }

  97%, 100% {
    opacity: 0;
    transform: translateY(8px) scale(.96) rotateX(4deg);
  }
}

@keyframes detailV5SelectionRing {
  0%, 7% {
    opacity: 0;
    transform: scale(.72) rotate(0deg);
  }

  13% {
    opacity: .95;
    transform: scale(1) rotate(18deg);
  }

  30% {
    opacity: .82;
    transform: translate(112px, -29px) scale(1.08) rotate(105deg);
  }

  46% {
    opacity: .32;
    transform: translate(133px, 105px) scale(.85) rotate(215deg);
  }

  57%, 100% {
    opacity: 0;
    transform: translate(105px, 211px) scale(.62) rotate(330deg);
  }
}

@keyframes detailV5TravelTrail {
  0%, 7% {
    opacity: 0;
    stroke-dashoffset: 150;
  }

  18% {
    opacity: .2;
  }

  44% {
    opacity: .72;
    stroke-dashoffset: 0;
  }

  61% {
    opacity: .15;
    stroke-dashoffset: -80;
  }

  70%, 100% {
    opacity: 0;
    stroke-dashoffset: -150;
  }
}

@keyframes detailV5PageTurn {
  0%, 49% {
    opacity: 0;
    transform: perspective(760px) rotateY(0deg) translateX(0) scaleX(1);
  }

  52% {
    opacity: 1;
    transform: perspective(760px) rotateY(-10deg) translateX(0) scaleX(1);
  }

  58% {
    opacity: .98;
    transform: perspective(760px) rotateY(-92deg) translateX(-3px) scaleX(.98);
  }

  64% {
    opacity: .86;
    transform: perspective(760px) rotateY(-166deg) translateX(-8px) scaleX(.96);
  }

  69%, 100% {
    opacity: 0;
    transform: perspective(760px) rotateY(-178deg) translateX(-12px) scaleX(.94);
  }
}

@media (max-width: 767px) {
  body.library-body .library-detail-bookshelf-v5 {
    width: min(96%, 410px);
    max-height: 450px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.library-body .detail-library-shelf-v5,
  body.library-body .detail-reading-desk-v5,
  body.library-body .detail-selected-book-v5,
  body.library-body .detail-selected-book-v5 .detail-book-closed,
  body.library-body .detail-open-book-v5,
  body.library-body .detail-selection-ring-v5,
  body.library-body .detail-selection-trail-v5,
  body.library-body .detail-open-book-v5 .detail-page-flip {
    animation: none !important;
  }

  body.library-body .detail-selected-book-v5,
  body.library-body .detail-selection-ring-v5,
  body.library-body .detail-selection-trail-v5 {
    display: none;
  }

  body.library-body .detail-open-book-v5 {
    opacity: 1;
    transform: none;
  }
}

/* END DETAIL BOOKSHELF UNIFY V5 */

/* BEGIN BOOKS LAND ON TABLE V6 */

/*
 * کتاب‌های متحرک اکنون نسبت به خودشان تبدیل می‌شوند، نه کل SVG.
 * این کار باعث می‌شود محل فرود دقیقاً روی سطح میز کنترل شود.
 */
body.library-body .library-moving-book,
body.library-body .library-book-grabber {
  transform-box: fill-box;
  transform-origin: center;
}

body.library-body .library-moving-book--one {
  animation-name: libraryPickBookOneOnTable;
}

body.library-body .library-book-grabber--one {
  animation-name: libraryGrabberOneOnTable;
}

body.library-body .library-moving-book--two {
  animation-name: libraryPickBookTwoOnTable;
}

body.library-body .library-book-grabber--two {
  animation-name: libraryGrabberTwoOnTable;
}

/*
 * کتاب اول از طبقه بالا بیرون می‌آید و روی بخش پایینی میز می‌نشیند.
 */
@keyframes libraryPickBookOneOnTable {
  0%, 8% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  13% {
    transform: translate(5px, -13px) rotate(-5deg) scale(1.02);
  }

  27% {
    transform: translate(92px, -31px) rotate(-14deg) scale(1.06);
  }

  44% {
    opacity: 1;
    transform: translate(148px, 78px) rotate(58deg) scale(1.08);
  }

  57% {
    transform: translate(118px, 176px) rotate(84deg) scale(1.05);
  }

  64% {
    transform: translate(110px, 194px) rotate(90deg) scale(1.04);
  }

  68% {
    transform: translate(110px, 205px) rotate(90deg) scale(.99);
  }

  72%, 80% {
    opacity: 1;
    transform: translate(110px, 201px) rotate(90deg) scale(1);
  }

  87%, 100% {
    opacity: 0;
    transform: translate(110px, 201px) rotate(90deg) scale(1);
  }
}

@keyframes libraryGrabberOneOnTable {
  0%, 7% {
    opacity: 0;
    transform: translate(0, 0) scale(.75) rotate(0deg);
  }

  12% {
    opacity: .95;
    transform: translate(5px, -13px) scale(1) rotate(18deg);
  }

  27% {
    opacity: .9;
    transform: translate(92px, -31px) scale(1.08) rotate(92deg);
  }

  44% {
    opacity: .72;
    transform: translate(148px, 78px) scale(.95) rotate(185deg);
  }

  57% {
    opacity: .42;
    transform: translate(118px, 176px) scale(.82) rotate(260deg);
  }

  67%, 100% {
    opacity: 0;
    transform: translate(110px, 201px) scale(.64) rotate(330deg);
  }
}

/*
 * کتاب دوم روی کتاب اول قرار می‌گیرد تا یک پشته واقعی روی میز بسازد.
 */
@keyframes libraryPickBookTwoOnTable {
  0%, 8% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  13% {
    transform: translate(6px, -11px) rotate(5deg) scale(1.02);
  }

  28% {
    transform: translate(74px, -31px) rotate(16deg) scale(1.06);
  }

  45% {
    opacity: 1;
    transform: translate(112px, 18px) rotate(60deg) scale(1.08);
  }

  57% {
    transform: translate(67px, 62px) rotate(84deg) scale(1.05);
  }

  64% {
    transform: translate(60px, 76px) rotate(90deg) scale(1.04);
  }

  68% {
    transform: translate(60px, 84px) rotate(90deg) scale(.99);
  }

  72%, 80% {
    opacity: 1;
    transform: translate(60px, 81px) rotate(90deg) scale(1);
  }

  87%, 100% {
    opacity: 0;
    transform: translate(60px, 81px) rotate(90deg) scale(1);
  }
}

@keyframes libraryGrabberTwoOnTable {
  0%, 7% {
    opacity: 0;
    transform: translate(0, 0) scale(.75) rotate(0deg);
  }

  12% {
    opacity: .95;
    transform: translate(6px, -11px) scale(1) rotate(-15deg);
  }

  28% {
    opacity: .9;
    transform: translate(74px, -31px) scale(1.06) rotate(-90deg);
  }

  45% {
    opacity: .7;
    transform: translate(112px, 18px) scale(.94) rotate(-180deg);
  }

  57% {
    opacity: .4;
    transform: translate(67px, 62px) scale(.82) rotate(-260deg);
  }

  67%, 100% {
    opacity: 0;
    transform: translate(60px, 81px) scale(.64) rotate(-330deg);
  }
}

/* هنگام فرود، پشته روی میز یک تکان بسیار کوتاه می‌خورد. */
body.library-body .library-desk-stack {
  animation-name: libraryDeskStackReceiveBooks;
}

@keyframes libraryDeskStackReceiveBooks {
  0%, 31%, 43%, 100% {
    transform: translateY(0) rotate(0deg);
  }

  34% {
    transform: translateY(2px) rotate(-.35deg);
  }

  37% {
    transform: translateY(-1px) rotate(.25deg);
  }

  50% {
    transform: translateY(2px) rotate(.3deg);
  }

  53% {
    transform: translateY(-1px) rotate(-.22deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.library-body .library-moving-book,
  body.library-body .library-book-grabber,
  body.library-body .library-desk-stack {
    animation: none !important;
  }

  body.library-body .library-book-grabber {
    display: none;
  }
}

/* END BOOKS LAND ON TABLE V6 */
