/* Khalwati R17 | additive layout polish. Same palette, same Tajawal typeface, same components. */
:root{--kh17-green:#07583d;--kh17-deep:#073f34;--kh17-gold:#c99a37;--kh17-line:#e6d6ae;--kh17-paper:#fffdf8;--kh17-cream:#fbf6e9;--kh17-muted:#6e746e;--kh17-tap:44px}

/* 1) Library category filters: 440px-tall 2-column grid on phones -> one swipeable row. */
@media (max-width:680px){
  html body :is(.library-tools.kh-filters-only,.library-tools) .filters{
    display:flex!important;flex-wrap:nowrap!important;grid-template-columns:none!important;
    overflow-x:auto!important;overflow-y:hidden!important;max-width:100%;contain:inline-size;gap:8px!important;padding:2px 2px 10px!important;margin-inline:-4px;
    scroll-snap-type:x proximity;-webkit-overflow-scrolling:touch;scrollbar-width:none;
    mask-image:linear-gradient(to left,#000 88%,transparent);-webkit-mask-image:linear-gradient(to left,#000 88%,transparent);
  }
  html body :is(.library-tools.kh-filters-only,.library-tools) .filters::-webkit-scrollbar{display:none}
  html body :is(.library-tools.kh-filters-only,.library-tools) .filters>.filter{
    flex:0 0 auto!important;width:auto!important;min-height:var(--kh17-tap);scroll-snap-align:start;
    display:inline-flex!important;flex-direction:row!important;align-items:center;gap:8px;padding:0 14px!important;border-radius:999px!important;white-space:nowrap;
  }
  html body :is(.library-tools.kh-filters-only,.library-tools) .filters .kh-filter-label{font-size:14px}
  html body :is(.library-tools.kh-filters-only,.library-tools) .filters .kh-filter-count{font-size:12.5px}
}

/* 2) Book page: comfortable tap targets on breadcrumb links. */
.crumbs a{display:inline-block;padding:10px 2px;margin:-10px 0}
.crumbs{line-height:2}

/* 3) Book page: related books (server-rendered by library-book.php R17). */
.kh17-related{margin-top:28px;padding-top:22px;border-top:1px solid var(--kh17-line)}
.kh17-related-head{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:4px 12px;margin:0 0 14px}
.kh17-related-head h2{margin:0;font-size:clamp(18px,2.2vw,22px);color:var(--kh17-deep);line-height:1.5}
.kh17-related-head a{color:var(--kh17-green);font-weight:800;text-decoration:none;white-space:nowrap;min-height:var(--kh17-tap);display:inline-flex;align-items:center}
.kh17-related-head a:hover{text-decoration:underline}
.kh17-related-grid{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:14px}
.kh17-related-grid a{display:flex;flex-direction:column;height:100%;text-decoration:none;color:var(--kh17-deep);background:var(--kh17-paper);border:1px solid var(--kh17-line);border-radius:18px;padding:10px;transition:transform .15s ease,box-shadow .15s ease}
.kh17-related-grid a:hover{transform:translateY(-2px);box-shadow:0 10px 26px rgba(7,63,52,.10)}
.kh17-related-grid a:focus-visible{outline:3px solid #ad8530;outline-offset:3px}
.kh17-related-cover{display:block;aspect-ratio:3/4;border-radius:12px;background:#f4ecd9;overflow:hidden}
.kh17-related-cover img{display:block;width:100%;height:100%;object-fit:contain}
.kh17-related-title{display:block;margin-top:10px;font-weight:800;font-size:15px;line-height:1.6;overflow-wrap:anywhere}
.kh17-related-meta{display:block;margin-top:2px;font-size:13px;color:var(--kh17-muted)}
@media (max-width:600px){
  .kh17-related-grid{display:flex;overflow-x:auto;scroll-snap-type:x proximity;gap:12px;padding-bottom:8px;scrollbar-width:thin}
  .kh17-related-grid li{flex:0 0 42%;scroll-snap-align:start}
}
@media (prefers-reduced-motion:reduce){.kh17-related-grid a{transition:none}}

/* 4) Desktop book page: keep the card from floating in empty space on wide screens. */
@media (min-width:1100px){
  .book-detail .detail-grid{align-items:start}
  .book-detail .detail-cover{position:sticky;top:96px}
}

/* 5) Small-text floor on phones (kickers, notes, footer). */
@media (max-width:680px){
  .app-simple-kicker,.app-simple-note,.kh-sawati-eyebrow,.footer-copy{font-size:13px!important}
}
