/* The Excellent Reader — Book Catalog Shared Styles (aligned with docs/site-navigation.md) */
*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light;
  --rr-paper: #fcfaf4;
  --rr-header-bg: #fffdf8;
  --rr-wash: #eef3eb;
  --rr-ink: #1e2927;
  --rr-ink-nav: #314b45;
  --rr-muted: #546763;
  --rr-green: #1f5c51;
  --rr-forest: #1f5c51;
  --rr-forest-soft: #e3f1ed;
  --rr-line: #dbe2d9;
  --rr-gold: #b88943;
  --rr-font-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --rr-font-sans: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--rr-font-sans);
  color: #1e293b;
  line-height: 1.5;
}

main {
  flex: 1;
  width: 100%;
}

[hidden] {
  display: none !important;
}

:where(a, button, input, select):focus-visible {
  outline: 3px solid var(--rr-gold);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  inset-inline-start: 12px;
  inset-block-start: -100px;
  background: #ffffff;
  color: var(--rr-ink);
  padding: 10px 14px;
  border: 1px solid var(--rr-line);
  border-radius: 8px;
  z-index: 100;
}

.skip:focus {
  inset-block-start: 12px;
}

/* Canonical Global Top Bar (.rr-global-header) */
.rr-global-header {
  background: var(--rr-header-bg);
  border-block-end: 1px solid var(--rr-line);
  color: var(--rr-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.rr-global-inner {
  max-inline-size: 1240px;
  margin-inline: auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}

.rr-global-brand {
  font: 700 1.55rem/1.2 var(--rr-font-serif);
  letter-spacing: -0.03em;
  color: var(--rr-forest);
  text-decoration: none;
  white-space: nowrap;
}

.rr-global-menu {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  flex-wrap: wrap;
  font-size: 0.96rem;
  line-height: 1.4;
  font-weight: 700;
}

.rr-global-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
}

.rr-global-adults {
  margin-inline-start: auto;
  border-inline-start: 1px solid var(--rr-line);
  padding-inline-start: 18px;
}

.rr-global-menu a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-block: 6px;
  white-space: nowrap;
  text-decoration: none;
  color: var(--rr-ink-nav);
  border-block-end: 2px solid transparent;
}

.rr-global-menu a:hover {
  color: var(--rr-forest);
}

.rr-global-menu a[aria-current="page"] {
  color: var(--rr-forest);
  border-block-end-color: currentColor;
}

.rr-global-menu a.rr-adult-link {
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--rr-muted);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--rr-wash);
  border-block-end: 0;
}

.rr-global-menu a.rr-adult-link:hover,
.rr-global-menu a.rr-adult-link[aria-current="page"] {
  color: var(--rr-forest);
  background: var(--rr-forest-soft);
}

.rr-nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 1.35rem;
  block-size: 1.35rem;
  padding-inline: 5px;
  border-radius: 999px;
  background: var(--rr-forest);
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 800;
}

@media (max-width: 820px) {
  .rr-global-inner { gap: 12px; }
  .rr-global-menu { gap: 12px; }
  .rr-global-adults { border-inline-start: 0; padding-inline-start: 0; }
}

@media (max-width: 560px) {
  .rr-global-inner { padding: 12px 16px; }
  .rr-global-menu { flex-basis: 100%; font-size: 0.86rem; justify-content: space-between; }
  .rr-global-group { gap: 4px 10px; }
  .rr-nav-count { min-inline-size: 1.2rem; block-size: 1.2rem; padding-inline: 4px; font-size: 0.68rem; }
}

@media (forced-colors: active) {
  .rr-global-menu a[aria-current="page"] { border-block-end-color: LinkText; }
}

/* Shared Parents & Teachers sub-bar (web-system site-navigation.md section 5; site-shell.css) */
.rr-section-nav {
  background: var(--rr-wash);
  border-block-end: 1px solid var(--rr-line);
  padding: 10px 24px;
  display: flex;
  gap: 10px 20px;
  justify-content: center;
  flex-wrap: wrap;
  font: 700 0.9rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.rr-section-nav a {
  color: var(--rr-forest);
  text-decoration: none;
}

.rr-section-nav a[aria-current] {
  text-decoration: underline;
  text-underline-offset: 5px;
}

.rr-nav-icon {
  flex-shrink: 0;
}

/* Quiet Shared Footer (.rr-global-footer) */
.rr-global-footer {
  margin-block-start: auto;
  background: var(--rr-header-bg);
  border-block-start: 1px solid var(--rr-line);
  padding: 18px 0;
  color: var(--rr-muted);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.84rem;
}

.rr-footer-inner {
  max-inline-size: 1240px;
  margin-inline: auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 24px;
}

.rr-footer-brand strong {
  font-family: var(--rr-font-serif);
  color: var(--rr-ink);
}

.rr-footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.rr-footer-label {
  font-size: 0.74rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rr-footer-links a {
  color: var(--rr-muted);
  text-decoration: none;
}

.rr-footer-links a:hover {
  color: var(--rr-forest);
  text-decoration: underline;
}

@media (max-width: 560px) {
  .rr-footer-inner { padding-inline: 16px; }
}

/* Real Book Cover Jacket */
.real-cover-wrap {
  position: relative;
  border-radius: 5px 10px 10px 5px;
  overflow: hidden;
  background: linear-gradient(145deg, var(--rc, #1e293b), #0f172a);
  box-shadow: -3px 0 0 rgba(0, 0, 0, 0.22) inset, 0 6px 16px rgba(15, 23, 42, 0.18);
  flex-shrink: 0;
}

.real-cover-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0%, rgba(255, 255, 255, 0.14) 5%, transparent 12%);
}

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

.cover-fallback {
  width: 100%;
  height: 100%;
  padding: 10px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  font-weight: 800;
}

.loan-ribbon {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 2;
  background: #15803d;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Native <dialog> Modals */
dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(2px);
}

#catalog-book-dialog,
#catalog-borrow-dialog {
  border: none;
  border-radius: 20px;
  max-width: 660px;
  width: calc(100% - 24px);
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  color: #0f172a;
  background: #ffffff;
  font-family: inherit;
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.32);
}

#catalog-borrow-dialog {
  max-width: 560px;
}

#catalog-book-dialog[open],
#catalog-borrow-dialog[open] {
  display: flex;
  flex-direction: column;
}

.cbd-top {
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(180deg, var(--cbd-bg, #f8fafc) 0%, #ffffff 100%);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.cbd-hero-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.cbd-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cbd-range-pill {
  font-size: 0.76rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--cbd-bg, #f1f5f9);
  color: var(--cbd-color, #0f172a);
  border: 1px solid var(--cbd-border, #cbd5e1);
}

.cbd-status-pill {
  font-size: 0.74rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}

.cbd-top h1 {
  font-size: 1.28rem;
  font-weight: 900;
  line-height: 1.25;
  margin: 6px 0 2px;
}

.cbd-sub {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--rr-green);
}

.cbd-author {
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 2px;
}

.cbd-close {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
  flex-shrink: 0;
}

.cbd-scroll {
  padding: 16px 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cbd-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 13px 15px;
}

.cbd-box h2 {
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin: 0 0 8px;
}

.cbd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cbd-btn {
  appearance: none;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  min-height: 42px;
}

.cbd-btn.primary {
  background: #6b1d3a;
  border-color: #6b1d3a;
  color: #ffffff;
}

.cbd-btn.primary.done {
  background: #15803d;
  border-color: #15803d;
}

.cbd-btn.hosted {
  background: #15803d;
  border-color: #15803d;
  color: #ffffff;
}

.cbd-warn {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 0.83rem;
  font-weight: 700;
}

.cbd-dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 12px;
  margin: 0;
}

.cbd-dl dt {
  font-size: 0.73rem;
  font-weight: 700;
  color: #64748b;
}

.cbd-dl dd {
  margin: 0;
  font-size: 0.87rem;
  font-weight: 800;
}

.cbd-related {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.cbd-rel-chip {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  border-radius: 8px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--rr-green);
  cursor: pointer;
}

.borrow-option-card {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 13px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.borrow-option-card.active-loan {
  border-color: #15803d;
  background: #f0fdf4;
}

.copy-toast {
  font-size: 0.8rem;
  font-weight: 800;
  color: #15803d;
}

/* body is a flex column, so a centered (margin: auto) row shrinks to its content width; an auto-fit grid of
   color stones then lays out as one 800px line on phones. Give those rows the full width and let them wrap. */
body > .stones-wrap,
body > .filter-row {
  width: 100%;
  box-sizing: border-box;
}

/* TK:17 - Worlds & Collections (Curation Pillars), Beloved Series and paged rendering, shared by both pages */
body > .worlds-row {
  width: 100%;
  box-sizing: border-box;
}

.worlds-row {
  max-width: 1120px;
  margin: 16px auto 0;
  padding: 0 18px;
}

.row-h {
  margin: 0 0 8px;
  font-size: 0.98rem;
  font-weight: 900;
  color: #1e3a8a;
}

.worlds-row.adult .row-h { color: #5b1933; }

.row-h-sub {
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b7280;
  margin-left: 6px;
}

.pillar-bar,
.series-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pillar-pill,
.series-chip {
  appearance: none;
  border: 2px solid #c7d2fe;
  background: #ffffff;
  color: #3730a3;
  border-radius: 999px;
  padding: 6px 13px;
  min-height: 38px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 900;
  cursor: pointer;
  max-width: 100%;
}

.series-chip {
  border-color: #fde68a;
  color: #92400e;
  font-size: 0.82rem;
  min-height: 34px;
  padding: 5px 11px;
}

.pillar-pill.on { background: #3730a3; border-color: #3730a3; color: #ffffff; }
.series-chip.on { background: #d97706; border-color: #d97706; color: #ffffff; }
.pillar-pill:disabled,
.series-chip:disabled { opacity: 0.4; cursor: default; }
.pillar-n,
.series-n { font-weight: 800; opacity: 0.8; }

.worlds-row.adult .pillar-pill { border-color: #e5e7eb; color: #5b1933; }
.worlds-row.adult .pillar-pill.on { background: #5b1933; border-color: #5b1933; color: #ffffff; }

.series-select-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  font-size: 0.86rem;
  font-weight: 800;
  color: #334155;
}

.series-select {
  flex: 1 1 240px;
  max-width: 100%;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
}

.pager {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 22px 0 0;
}

.pager-note {
  font-size: 0.88rem;
  font-weight: 800;
  color: #475569;
}

.show-more {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  min-height: 44px;
  font: inherit;
  font-size: 0.94rem;
  font-weight: 900;
  cursor: pointer;
  background: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 4px 0 #1e3a8a;
}

.show-more.adult-more { background: #7f1d45; box-shadow: 0 4px 0 #5b1933; }

/* ---- My Library (TK:18): the picker dialog, the info card and the header controls */
#catalog-library-dialog {
  border: none;
  border-radius: 20px;
  max-width: 600px;
  width: calc(100% - 24px);
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  color: #0f172a;
  background: #ffffff;
  font-family: inherit;
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.32);
}
#catalog-library-dialog[open] { display: flex; flex-direction: column; }
.clp-top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 20px 12px; border-bottom: 1px solid #e2e8f0;
}
.clp-top h1 { margin: 0; font-size: 1.25rem; font-weight: 900; }
.clp-body { padding: 14px 20px 20px; overflow-y: auto; min-height: 0; }
.clp-help { margin: 0 0 10px; font-size: 0.85rem; color: #475569; }
.clp-saved { display: grid; gap: 8px; margin-bottom: 12px; }
.clp-card {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 12px; background: #f8fafc;
}
.clp-card-k { font-size: 0.7rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; color: #64748b; }
.clp-card-n { font-weight: 900; }
.clp-card-m { font-size: 0.8rem; color: #475569; margin-bottom: 4px; }
.clp-card-b { display: flex; gap: 6px; flex-wrap: wrap; }
.clp-search-wrap { display: block; margin-bottom: 10px; }
.clp-label { display: block; font-size: 0.82rem; font-weight: 800; margin-bottom: 4px; }
#clp-q {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 1rem;
  padding: 10px 12px; border: 2px solid #94a3b8; border-radius: 12px;
}
#clp-q:focus { outline: none; border-color: #2563eb; }
.clp-chips-h { font-size: 0.76rem; font-weight: 900; color: #64748b; margin: 4px 0 6px; }
.clp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.clp-chip {
  appearance: none; font: inherit; font-size: 0.8rem; font-weight: 800; cursor: pointer;
  padding: 5px 11px; border-radius: 999px; border: 1px solid #cbd5e1; background: #fff; color: #0f172a;
}
.clp-chip.synced { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.clp-chip:hover { border-color: #2563eb; }
.clp-status { font-size: 0.82rem; font-weight: 800; color: #475569; margin: 4px 0 6px; }
.clp-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.clp-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 12px;
}
.clp-row-main { flex: 1; min-width: 200px; }
.clp-row-n { font-weight: 900; }
.clp-row-m { font-size: 0.8rem; color: #475569; margin-bottom: 4px; }
.clp-row-b { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-tier {
  display: inline-block; font-size: 0.72rem; font-weight: 900; padding: 2px 9px; border-radius: 999px;
}
.lib-tier.synced { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.lib-tier.direct { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.my-lib-btn {
  appearance: none; font: inherit; font-size: 0.85rem; font-weight: 900; cursor: pointer;
  padding: 8px 13px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.14); color: inherit; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.my-lib-btn:hover { background: rgba(255, 255, 255, 0.24); }
.my-lib-chip {
  appearance: none; font: inherit; font-size: 0.8rem; font-weight: 900; cursor: pointer;
  padding: 5px 12px; border-radius: 999px; border: 1px solid #cbd5e1; background: #fff; color: #0f172a;
}
.my-lib-card-wrap { max-width: 1120px; margin: 10px auto 0; }
.lib-info {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 14px; background: #ffffff; color: #0f172a;
  border: 1px solid #e2e8f0;
}
.lib-info-name { font-weight: 900; }
.lib-info-meta { font-size: 0.8rem; color: #475569; margin-bottom: 4px; }
.lib-info-links { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-link {
  appearance: none; font: inherit; font-size: 0.8rem; font-weight: 800; cursor: pointer; text-decoration: none;
  padding: 6px 11px; border-radius: 10px; border: 1px solid #cbd5e1; background: #f8fafc; color: #0f172a;
}
.lib-link.strong { background: #0f172a; color: #ffffff; border-color: #0f172a; }
