/* Darsliklar — barcha mavjud fan palitralaridan foydalanadi. */
html body.fh-desktop-fit #fh-textbook-view { box-sizing: border-box; width: 100%; min-width: 0; padding: clamp(4px, 1vw, 16px); color: var(--fh-mode-text); }
#fh-textbook-view *, #fh-textbook-view *::before { box-sizing: border-box; }
html body.fh-desktop-fit #fh-textbook-view[hidden], #fh-textbook-view [hidden] { display: none !important; }
html:has(.sidebar [data-fh-section="textbooks"][aria-current="page"]) .main > .topbar { display: none !important; }
#fh-textbook-view .fh-books-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 24px; color: var(--fh-mode-muted); font-size: 15px; line-height: 1.4; }
#fh-textbook-view .fh-books-crumb button { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
#fh-textbook-view .fh-books-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
#fh-textbook-view .fh-books-kicker { margin: 0 0 10px; color: var(--fh-tinted-light); font-size: 12px; font-weight: 700; letter-spacing: .13em; }
#fh-textbook-view h1 { margin: 0 0 12px; color: var(--fh-mode-accent); font-size: clamp(30px, 3vw, 42px); line-height: 1.15; }
#fh-textbook-view .fh-books-header div > p:last-child { max-width: 640px; margin: 0; color: var(--fh-mode-muted); font-size: 18px; line-height: 1.5; }
#fh-textbook-view .fh-books-total { flex: 0 0 auto; margin-top: 8px; border: 1px solid var(--fh-panel-line); border-radius: 13px; padding: 10px 13px; background: var(--fh-control-paint); color: var(--fh-mode-muted); font-size: 15px; }
#fh-textbook-view .fh-books-grades { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
#fh-textbook-view .fh-books-grades button { min-height: 40px; padding: 9px 14px; border: 1px solid var(--fh-panel-line); border-radius: 11px; background: var(--fh-mode-input); color: var(--fh-mode-muted); font: inherit; font-size: 16px; cursor: pointer; }
#fh-textbook-view .fh-books-grades button[aria-pressed="true"] { background: var(--fh-glass-paint); border-color: var(--fh-mode-line); color: var(--fh-mode-text); }
#fh-textbook-view .fh-books-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, .45fr); gap: 16px; }
#fh-textbook-view .fh-books-filters label { display: grid; min-width: 0; gap: 8px; font-size: 15px; font-weight: 600; }
#fh-textbook-view :is(input, select) { width: 100%; min-width: 0; min-height: 47px; border: 1px solid var(--fh-panel-line); border-radius: 13px; padding: 11px 14px; color: var(--fh-mode-text); background: var(--fh-mode-input); font: inherit; font-size: 17px; }
#fh-textbook-view input::placeholder { color: var(--fh-mode-muted); opacity: .8; }
#fh-textbook-view .fh-books-results { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 20px 0; color: var(--fh-mode-muted); font-size: 16px; }
#fh-textbook-view .fh-books-results p { margin: 0; }
:is(#fh-textbook-view [data-books-reset], #fh-certificate-calculator [data-total-reset]) { border: 0; padding: 4px 0; background: none; color: var(--fh-mode-accent); font: inherit; font-size: 15px; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
#fh-textbook-view .fh-books-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
#fh-textbook-view .fh-book { display: flex; flex-direction: column; min-width: 0; padding: 20px; border: 1px solid transparent; border-radius: 22px; background: var(--fh-panel-paint) padding-box, linear-gradient(140deg, var(--fh-mode-accent), var(--fh-panel-line) 40%, var(--fh-panel-line)) border-box; }
#fh-textbook-view .fh-book-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 19px; }
#fh-textbook-view .fh-book-icon { display: grid; place-items: center; flex: 0 0 48px; width: 48px; height: 48px; border: 1px solid var(--fh-panel-line); border-radius: 14px; background: var(--fh-badge-paint); color: var(--fh-mode-accent); }
#fh-textbook-view .fh-book-icon svg { width: 28px; height: 28px; }
#fh-textbook-view .fh-book-grade { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--fh-panel-line); background: var(--fh-control-paint); color: var(--fh-mode-muted); font-size: 13px; }
#fh-textbook-view .fh-book h2 { margin: 0 0 12px; color: var(--fh-mode-text); font-size: 23px; line-height: 1.2; overflow-wrap: anywhere; }
#fh-textbook-view .fh-book-info { margin: 0 0 6px; color: var(--fh-mode-muted); font-size: 15px; }
#fh-textbook-view .fh-book-open { display: block; margin-top: auto; padding: 10px 12px; border: 1px solid var(--fh-panel-line); border-radius: 10px; background: var(--fh-control-paint); color: var(--fh-mode-text); text-align: center; text-decoration: none; font-size: 16px; font-weight: 600; }
#fh-textbook-view .fh-book-open:hover { background: var(--fh-glass-paint); border-color: var(--fh-mode-line); }
#fh-textbook-view .fh-book-download { padding-top: 9px; text-align: center; color: var(--fh-mode-accent); font-size: 15px; text-underline-offset: 3px; }
#fh-textbook-view .fh-book-unavailable { display: block; margin-top: auto; padding: 10px 0; color: var(--fh-mode-muted); font-size: 15px; }
#fh-textbook-view .fh-books-more { display: block; min-height: 45px; margin: 24px auto 0; padding: 10px 24px; border: 1px solid var(--fh-mode-line); border-radius: 13px; background: var(--fh-control-paint); color: var(--fh-mode-text); font: inherit; font-size: 17px; cursor: pointer; }
#fh-textbook-view :is(a, button, input, select):focus-visible { outline: 2px solid var(--fh-mode-accent); outline-offset: 3px; }
@media (max-width: 1199px) { #fh-textbook-view .fh-books-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 950px) { #fh-textbook-view .fh-books-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } #fh-textbook-view .fh-books-header { flex-direction: column; gap: 14px; } }
@media (max-width: 700px) { #fh-textbook-view .fh-books-filters { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 420px) { #fh-textbook-view .fh-books-grid { grid-template-columns: minmax(0, 1fr); } #fh-textbook-view .fh-books-results { align-items: flex-start; } }

/* Sinflar: joylashuvni surmasdan, Dock kabi yengil ko‘tarilish. */
#fh-textbook-view .fh-books-grades {
  padding-block: 7px;
  margin-top: -7px;
  gap: 8px;
}
#fh-textbook-view .fh-books-grades button {
  transform-origin: 50% 100%;
  transition: transform 260ms cubic-bezier(.2,.8,.2,1),
    background-color 200ms ease, border-color 200ms ease, box-shadow 260ms ease;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
  #fh-textbook-view .fh-books-grades button:hover {
    transform: translateY(-5px) scale(1.055);
    border-color: var(--fh-mode-line);
    color: var(--fh-mode-text);
    box-shadow: 0 6px 12px rgb(0 0 0 / 16%);
  }
  #fh-textbook-view .fh-books-grades button:has(+ button:hover),
  #fh-textbook-view .fh-books-grades button:hover + button {
    transform: translateY(-2px) scale(1.025);
  }
}
#fh-textbook-view .fh-books-grades button:focus-visible { transform: translateY(-3px); }
#fh-textbook-view .fh-books-grades button:active { transform: translateY(-1px) scale(.97); }

/* Filtrni tozalash — havola emas, mavzuga mos tugma. */
:is(#fh-textbook-view [data-books-reset], #fh-certificate-calculator [data-total-reset]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--fh-mode-line);
  border-radius: 12px;
  background: var(--fh-control-paint, var(--fh-mode-control));
  color: var(--fh-mode-text);
  text-decoration: none;
  font-weight: 600;
  transition: transform 240ms cubic-bezier(.2,.8,.2,1), box-shadow 240ms ease,
    border-color 200ms ease;
}
:is(#fh-textbook-view [data-books-reset], #fh-certificate-calculator [data-total-reset]) svg { flex: 0 0 18px; width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  :is(#fh-textbook-view [data-books-reset], #fh-certificate-calculator [data-total-reset]):hover {
    transform: translateY(-2px);
    border-color: var(--fh-mode-accent);
    box-shadow: 0 5px 12px rgb(0 0 0 / 15%);
  }
}
:is(#fh-textbook-view [data-books-reset], #fh-certificate-calculator [data-total-reset]):active { transform: translateY(0) scale(.97); }

/* Fan menyusi: tanlangan mavzuning barcha ranglari shu o‘zgaruvchilardan olinadi. */
#fh-textbook-view .fh-books-subject-field {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}
#fh-textbook-view .fh-subject-picker { position: relative; min-width: 0; z-index: 2; }
#fh-textbook-view .fh-subject-picker.is-open { z-index: 20; }
#fh-textbook-view .fh-subject-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: 47px;
  padding: 11px 14px;
  border: 1px solid var(--fh-panel-line, var(--fh-mode-line));
  border-radius: 13px;
  color: var(--fh-mode-text);
  background: var(--fh-mode-input);
  font: inherit;
  font-size: 17px;
  text-align: left;
  cursor: pointer;
  transition: border-color 200ms ease, box-shadow 200ms ease, transform 160ms ease;
}
#fh-textbook-view #fh-books-subject-value {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#fh-textbook-view .fh-subject-trigger:hover { border-color: var(--fh-mode-line); }
#fh-textbook-view .fh-subject-trigger:active { transform: scale(.99); }
#fh-textbook-view .fh-subject-trigger[aria-expanded="true"] {
  border-color: var(--fh-mode-accent);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--fh-mode-accent) 12%, transparent);
}
#fh-textbook-view .fh-subject-chevron {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  transition: transform 260ms cubic-bezier(.2,.8,.2,1);
}
#fh-textbook-view .is-open .fh-subject-chevron { transform: rotate(180deg); }
#fh-textbook-view .fh-subject-options {
  position: absolute;
  z-index: 30;
  top: calc(100% + 9px);
  left: 0;
  width: 100%;
  max-height: var(--fh-subject-menu-height, 330px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--fh-mode-line) transparent;
  scrollbar-gutter: stable;
  padding: 7px;
  border: 1px solid var(--fh-mode-line);
  border-radius: 16px;
  background: var(--fh-mode-panel);
  color: var(--fh-mode-text);
  box-shadow: 0 14px 30px rgb(0 0 0 / 28%);
  transform-origin: 50% 0;
}
#fh-textbook-view .opens-up .fh-subject-options {
  top: auto;
  bottom: calc(100% + 9px);
  transform-origin: 50% 100%;
}
#fh-textbook-view .fh-subject-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  margin: 2px 0;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1.35;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
#fh-textbook-view .fh-subject-option > span { min-width: 0; overflow-wrap: anywhere; }
#fh-textbook-view .fh-subject-option svg {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 150ms ease;
}
#fh-textbook-view .fh-subject-option[aria-selected="true"] {
  background: var(--fh-mode-active);
  border-color: var(--fh-mode-line);
  font-weight: 700;
}
#fh-textbook-view .fh-subject-option[aria-selected="true"] svg { opacity: 1; }
#fh-textbook-view .fh-subject-option.is-active {
  background: var(--fh-mode-control);
  border-color: var(--fh-mode-accent);
}
#fh-textbook-view .fh-book-edition {
  margin: 0 0 22px;
  color: var(--fh-mode-muted);
  font-size: 15px;
  line-height: 1.4;
}
@media (max-width: 420px) {
  :is(#fh-textbook-view [data-books-reset], #fh-certificate-calculator [data-total-reset]) { font-size: 14px; padding: 9px 10px; }
  #fh-textbook-view .fh-books-results { flex-wrap: wrap; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  #fh-textbook-view :is(.fh-books-grades button, [data-books-reset], .fh-subject-trigger,
    .fh-subject-chevron, .fh-subject-option, .fh-subject-option svg) { transition: none !important; }
  #fh-textbook-view .fh-books-grades button,
  :is(#fh-textbook-view [data-books-reset], #fh-certificate-calculator [data-total-reset]),
  #fh-textbook-view .fh-subject-trigger { transform: none !important; }
}



@media(prefers-reduced-motion:reduce){
  :is(#fh-textbook-view [data-books-reset],#fh-certificate-calculator [data-total-reset]) {transition:none!important;transform:none!important;}
}
