/* NEwBOO web parity, slice 1: public shell, catalog and BookCard.
   Sources: backend/app/web/static/css/{00-tokens.css,components/header.css,
   components/footer.css,components/book-card.css,components/empty-state.css,
   components/page-header.css,pages/home.css,pages/catalog.css}.
   Keep unsupported storefront/recommendation features hidden, not fabricated. */
:root {
  color-scheme: light;
  --bg-main: #f7f7f8;
  --bg-surface: #fff;
  --bg-secondary: #f9fafb;
  --text-main: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --border-dark: #d1d5db;
  --primary-color: #4f46e5;
  --action-primary-bg: #0f172a;
  --action-primary-bg-hover: #111827;
  --action-primary-text: #fff;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --book-card-bg: #fff;
  --book-card-border: #e5e7eb;
  --book-card-border-hover: #94a3b8;
  --book-card-cover-bg: #f1f5f9;
  --book-card-cover-text: #64748b;
  --book-card-title: #111827;
  --book-card-meta: #6b7280;
  --book-card-shadow-hover: 0 16px 34px rgba(15, 23, 42, .12);
  --focus-ring-color: rgba(79, 70, 229, .28);
}
html { background: var(--bg-main); }
body {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  background: var(--bg-main);
  color: var(--text-main);
}
#main { flex: 1 0 auto; }
.container { width: min(1200px, calc(100% - 40px)); margin-inline: auto; }
:focus-visible { outline: 3px solid var(--primary-color); outline-offset: 3px; }
.button { background: var(--action-primary-bg); border-color: var(--action-primary-bg); }
.button:hover:not(:disabled) { background: var(--action-primary-bg-hover); }
.button--quiet { background: var(--bg-surface); color: var(--text-main); border-color: var(--border-color); }
.button--quiet:hover:not(:disabled) { background: var(--bg-secondary); }
.text-link { color: var(--primary-color); }
.eyebrow { color: var(--text-muted); }
.page-description { color: var(--text-muted); }
.site-header { position: relative; z-index: 1000; border-bottom: 1px solid var(--border-color); background: var(--bg-surface); }
.site-header__inner { max-width: 1200px; min-height: 72px; margin: auto; padding-block: 12px; }
.site-logo {
  display: block;
  flex: 0 0 auto;
  width: 168px;
  height: 36px;
  background: url("/assets/brand/pandaolate-header.png") no-repeat left center / contain;
}
.site-nav { gap: 16px; }
.site-nav__link { color: var(--text-main); font-size: 14px; font-weight: 750; }
.site-nav__link:hover { color: var(--primary-color); }
.site-header__auth { display: flex; align-items: center; gap: 12px; }
.site-header__auth .button { min-height: 40px; padding: 8px 14px; }
.site-header__auth .site-nav__link { min-height: 40px; display: inline-flex; align-items: center; }
.site-mobile-menu { display: none; }
.site-footer { flex: 0 0 auto; padding: 20px 0 42px; border-top: 0; background: var(--bg-main); }
.site-footer__inner {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(150px, 1fr));
  gap: 26px;
  padding: 28px;
  border-top: 1px solid var(--border-color);
  background: linear-gradient(180deg, rgba(255,255,255,.8), transparent);
}
.site-footer__brand, .site-footer__column { min-width: 0; }
.site-footer__logo { display: inline-flex; margin-bottom: 10px; font-size: 20px; font-weight: 950; text-decoration: none; }
.site-footer__text { max-width: 300px; margin: 0; color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.site-footer__title { margin: 0 0 12px; color: var(--text-main); font-size: 13px; font-weight: 900; text-transform: uppercase; }
.site-footer__column { display: grid; align-content: start; gap: 9px; }
.site-footer__link { color: var(--text-muted); font-size: 14px; text-decoration: none; }
.site-footer__link:hover { color: var(--primary-color); }
.section { padding-block: 40px; }
.ui-page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 18px; }
.ui-page-header__kicker { color: var(--primary-color); font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.ui-page-header__title { margin: 8px 0 12px; color: var(--text-main); font-size: clamp(32px,4vw,44px); line-height: 1.1; letter-spacing: -.04em; }
.ui-page-header__text { margin: 0; max-width: 660px; color: var(--text-muted); font-size: 15px; line-height: 1.6; }
.ui-empty-state { padding: 22px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-secondary); }
.ui-empty-state__title { margin: 0 0 6px; font-size: 18px; color: var(--text-main); }
.ui-empty-state__text { margin: 0; color: var(--text-muted); }
.catalog-page { min-height: 65vh; }
.catalog-result-count { margin: -6px 0 18px; color: var(--text-muted); font-size: 14px; font-weight: 700; }
.catalog-filters { display: grid; grid-template-columns: minmax(210px, 1.6fr) minmax(120px, 1fr) minmax(115px, .8fr) auto; gap: 10px; align-items: center; margin-bottom: 22px; }
.ui-input, .ui-select { min-width: 0; min-height: 42px; width: 100%; padding: 8px 12px; border: 1px solid var(--border-dark); border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text-main); font: inherit; }
.ui-input:focus-visible, .ui-select:focus-visible { border-color: var(--primary-color); box-shadow: 0 0 0 3px var(--focus-ring-color); outline: 0; }
.ui-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 16px; border: 1px solid var(--action-primary-bg); border-radius: var(--radius-sm); background: var(--action-primary-bg); color: var(--action-primary-text); font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
.ui-button--ghost { border-color: var(--border-color); background: var(--bg-surface); color: var(--text-main); }
.ui-button:hover { filter: brightness(.94); }
.ui-button--small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.catalog-grid, .book-grid, .book-grid--catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 14px; margin-top: 0; }
.book-mini-card { min-width: 0; }
.book-mini-card__link { display: block; height: 100%; padding: 10px; border: 1px solid var(--book-card-border); border-radius: var(--radius-xl); background: var(--book-card-bg); color: inherit; text-decoration: none; transition: transform .15s ease,border-color .15s ease,box-shadow .15s ease; }
.book-mini-card__link:hover { transform: translateY(-2px); border-color: var(--book-card-border-hover); box-shadow: var(--book-card-shadow-hover); }
.book-mini-card__link:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--focus-ring-color); }
.book-mini-card__cover { display: flex; width: 100%; aspect-ratio: 2/3; align-items: center; justify-content: center; overflow: hidden; border-radius: var(--radius-lg); background: var(--book-card-cover-bg); color: var(--book-card-cover-text); font-size: 13px; font-weight: 900; text-align: center; }
.book-mini-card__body { padding-top: 10px; }
.book-mini-card__title { margin: 0; color: var(--book-card-title); font-size: 15px; font-weight: 900; line-height: 1.25; letter-spacing: -.025em; overflow-wrap: anywhere; }
.book-mini-card__meta { margin-top: 5px; color: var(--book-card-meta); font-size: 12px; font-weight: 750; }
.book-mini-card--compact .book-mini-card__link { padding: 8px; border-radius: var(--radius-md); }
.book-mini-card--compact .book-mini-card__cover { border-radius: var(--radius-sm); }
.book-mini-card--compact .book-mini-card__title { font-size: 13px; }
.home-hero { padding: 24px 0 18px; }
.home-page__title { max-width: 760px; margin: 0 0 18px; color: var(--text-main); font-size: clamp(30px,4vw,48px); line-height: 1.05; letter-spacing: -.04em; text-wrap: balance; }
.home-special { min-width: 0; }
.home-showcase { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; min-height: 200px; padding: 28px; border-radius: var(--radius-xl); background: var(--bg-secondary); border: 1px solid var(--border-color); }
.home-showcase__text { max-width: 560px; margin: 0; color: var(--text-muted); line-height: 1.6; }
.home-section-header-row { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.home-section-header-row .ui-section-header { margin-bottom: 0; }
.ui-section-header__title { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: -.035em; }
@media (max-width: 820px) {
  .catalog-filters { grid-template-columns: 1fr 1fr; }
  .catalog-filters__search { grid-column: 1 / -1; }
  .catalog-filters__submit { grid-column: 1 / -1; }
  .site-footer__inner { grid-template-columns: 1fr 1fr; }
  .site-footer__brand { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .container { width: min(100% - 28px, 1200px); }
  .site-header__inner { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
  .site-logo { width: 133px; height: 30px; }
  .site-header .site-nav { display: none; }
  .site-header__auth .button { display: none; }
  .site-mobile-menu { display: block; position: relative; }
  .site-mobile-menu__trigger { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-secondary); color: var(--text-main); cursor: pointer; }
  .site-mobile-menu__panel { position: absolute; z-index: 1300; left: 0; top: calc(100% + 12px); width: min(300px, calc(100vw - 28px)); padding: 14px; border: 1px solid var(--border-color); border-radius: 16px; background: var(--bg-surface); box-shadow: 0 20px 45px rgba(15,23,42,.15); }
  .site-mobile-nav { display: grid; gap: 8px; }
  .site-mobile-nav__link { min-height: 44px; display: flex; align-items: center; padding: 10px; border-radius: 10px; text-decoration: none; font-size: 14px; font-weight: 750; }
  .site-mobile-nav__link:focus-visible,.site-mobile-nav__link:hover { background: var(--bg-secondary); }
  .site-footer__inner { grid-template-columns: 1fr; padding-inline: 0; }
  .catalog-filters { grid-template-columns: 1fr; }
  .catalog-filters__search, .catalog-filters__submit { grid-column: auto; }
  .catalog-grid, .book-grid { grid-template-columns: repeat(auto-fill,minmax(126px,1fr)); gap: 12px; }
  .home-section-header-row { flex-direction: column; align-items: flex-start; }
  .home-showcase { grid-template-columns: 1fr; }
}


/* H-web-02 — original NEwBOO form and mascot. Existing Rust/PG validation
   and strict script-src none are preserved. The panda remains useful without JS.
   Source: newboo/backend/app/web/static/css/components/auth-shell.css */
:root {
  --auth-panda-ink: #101317;
  --auth-panda-face: #fff;
  --auth-panda-highlight: rgba(255,255,255,.88);
}
.auth-section { background: var(--bg-main); }
.auth-card--newboo {
  width: min(510px, 100%);
  display: grid;
  gap: 18px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  box-shadow: 0 16px 40px color-mix(in srgb, var(--text-main) 8%, transparent);
  border-radius: var(--radius-xl);
}
.auth-card--newboo .auth-card__header {
  display: grid;
  gap: 7px;
}
.auth-card--newboo .auth-card__header > * { margin: 0; }
.auth-card--newboo .auth-card__kicker {
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.auth-card--newboo .auth-card__title {
  color: var(--text-main);
  font-size: clamp(30px,7vw,42px);
  line-height: 1.05;
}
.auth-card--newboo .auth-card__text {
  color: var(--text-muted);
  line-height: 1.55;
}
.auth-card--newboo .auth-form {
  display: grid;
  gap: 10px;
  margin: 0;
}
.auth-card--newboo .auth-form label { color: var(--text-main); }
.auth-card--newboo .auth-form input {
  background: var(--bg-surface);
  border: 1px solid var(--border-dark);
  color: var(--text-main);
  margin-bottom: 8px;
}
.auth-card--newboo .auth-form input:focus-visible {
  outline: 0;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--focus-ring-color);
}
.auth-card--newboo .auth-card__footer { margin: 0; color: var(--text-muted); }
.auth-card--newboo .auth-card__footer a { color: var(--primary-color); }
.auth-card--newboo .auth-form__help { margin: -10px 0 7px; }

/* Pandaolate auth mascot. The card keeps the actual form as the main focus;
   the panda only peeks over the edge and uses two tiny paw poses: resting on the
   card in the normal state, then covering the glasses in the password state. */
.auth-card--newboo {
  position: relative;
  margin-top: 96px;
  padding-top: 110px;
  overflow: visible;
}
.auth-panda {
  position: absolute;
  z-index: 0;
  top: -112px;
  left: 50%;
  width: 254px;
  height: 186px;
  transform: translateX(-50%);
  pointer-events: none;
  user-select: none;
}
.auth-panda__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 10px 18px color-mix(in srgb, var(--text-main) 8%, transparent));
}
.auth-panda__ear,
.auth-panda__patch,
.auth-panda__nose,
.auth-panda__pupil,
.auth-panda__paw,
.auth-panda__arm-stroke {
  fill: var(--auth-panda-ink);
}
.auth-panda__face,
.auth-panda__eye-white {
  fill: var(--auth-panda-face);
}
.auth-panda__face {
  stroke: var(--auth-panda-ink);
  stroke-width: 4.5;
}
.auth-panda__tuft,
.auth-panda__whisker,
.auth-panda__brow,
.auth-panda__mouth,
.auth-panda__glasses {
  fill: none;
  stroke: var(--auth-panda-ink);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.auth-panda__tuft {
  stroke-width: 3.5;
}
.auth-panda__whisker {
  stroke-width: 2.8;
}
.auth-panda__brow {
  stroke-width: 6.5;
}
.auth-panda__mouth {
  stroke-width: 3.8;
}
.auth-panda__glasses {
  stroke-width: 6.5;
}
.auth-panda__spark,
.auth-panda__claw {
  fill: var(--auth-panda-highlight);
}
.auth-panda__head {
  transform-box: view-box;
  transform-origin: 130px 122px;
  transition: transform 240ms cubic-bezier(0.2, 0.78, 0.25, 1);
}
.auth-panda__eye--left,
.auth-panda__eye--right {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 180ms ease;
}
.auth-panda__rest-paw,
.auth-panda__cover-arm {
  transform-box: view-box;
  transform-origin: center;
  transition: transform 320ms cubic-bezier(0.22, 0.9, 0.24, 1), opacity 220ms ease;
}
.auth-panda__rest-paws {
  transition: opacity 180ms ease;
}
.auth-panda__cover-arm--left {
  transform-origin: 82px 148px;
  transform: translateY(10px) rotate(-10deg);
  opacity: 0;
}
.auth-panda__cover-arm--right {
  transform-origin: 178px 148px;
  transform: translateY(10px) rotate(10deg);
  opacity: 0;
}
.auth-panda.is-watching .auth-panda__head {
  transform: translateY(3px);
}
.auth-panda.is-watching .auth-panda__eye--left,
.auth-panda.is-watching .auth-panda__eye--right {
  transform: translateY(3px);
}
.auth-panda.is-watching .auth-panda__rest-paw--left,
.auth-panda.is-watching .auth-panda__rest-paw--right {
  transform: translateY(-2px);
}
.auth-panda.is-hiding-password .auth-panda__head {
  transform: translateY(5px);
}
.auth-panda.is-hiding-password .auth-panda__rest-paws {
  opacity: 0;
}
.auth-panda.is-hiding-password .auth-panda__rest-paw--left {
  transform: translate(-5px, 6px) rotate(-12deg);
}
.auth-panda.is-hiding-password .auth-panda__rest-paw--right {
  transform: translate(5px, 6px) rotate(12deg);
}
.auth-panda.is-hiding-password .auth-panda__cover-arm--left {
  transform: translateY(0) rotate(0deg);
  opacity: 1;
}
.auth-panda.is-hiding-password .auth-panda__cover-arm--right {
  transform: translateY(0) rotate(0deg);
  opacity: 1;
}
/* Keep real form content above the mascot body where the two overlap. */
.auth-card__header,
.auth-form,
.auth-oauth-divider,
.auth-hint,
.auth-card > .ui-alert,
.auth-card > .ui-button {
  position: relative;
  z-index: 1;
}
@media (max-width: 640px) {
  .auth-card--newboo {
    margin-top: 78px;
    padding-top: 92px;
  }
  .auth-panda {
    top: -98px;
    width: 224px;
    height: 164px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .auth-panda__head,
  .auth-panda__eye--left,
  .auth-panda__eye--right,
  .auth-panda__rest-paw,
  .auth-panda__rest-paws,
  .auth-panda__cover-arm {
    transition-duration: 1ms;
  }
}


/* Original mascot's password-cover pose without adding script to CSP-protected
   registration/login. Chromium & modern browsers support :has(). */
.auth-card--newboo:has(input[type=password]:focus) .auth-panda__head { transform: translateY(5px); }
.auth-card--newboo:has(input[type=password]:focus) .auth-panda__rest-paws { opacity: 0; }
.auth-card--newboo:has(input[type=password]:focus) .auth-panda__cover-arm--left,
.auth-card--newboo:has(input[type=password]:focus) .auth-panda__cover-arm--right {
  transform: translateY(0) rotate(0deg);
  opacity: 1;
}


/* H-web-03: NEwBOO `templates/me/index.html`, original page styles, and
   components/dashboard-tile.css and dashboard-nav.css. Only real TOR links. */
.me-page {
  --neutral-bg: #f3f4f6;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --info-bg: #eef2ff;
  --info-border: #c7d2fe;
}
.me-page__logout { margin: 0; flex: 0 0 auto; }
.me-role-card__status {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}
.me-page .ui-section-header { margin-bottom: 14px; }
.me-page .ui-section-header__text {
  color: var(--text-muted);
  margin: 6px 0 0;
  font-size: 14px;
}
.me-page .me-role-card__value {
  white-space: normal;
  overflow-wrap: anywhere;
  text-overflow: clip;
}
@media (max-width: 640px) {
  .me-page .ui-page-header { flex-direction: column; align-items: stretch; }
  .me-page__logout { align-self: flex-start; }
  .me-page .container { min-width: 0; }
}
.dashboard-nav {
  display: flex;
  max-width: 100%;
  min-height: 44px;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.dashboard-nav::-webkit-scrollbar {
  display: none;
}

.dashboard-nav__item {
  display: inline-flex;
  box-sizing: border-box;
  flex: 0 0 auto;
  min-width: 0;
  height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}

.dashboard-nav__item.is-active {
  background: var(--text-main);
  color: var(--bg-surface);
  border-color: var(--text-main);
}

.dashboard-nav__item.is-disabled {
  cursor: default;
  opacity: 0.55;
}


.dashboard-tile {
  position: relative;
  min-width: 0;
  min-height: 124px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background-color 0.16s ease;
}
.dashboard-tile--reader {
  border-color: var(--success-border);
  background: color-mix(in srgb, var(--bg-surface) 88%, var(--success-bg));
}
.dashboard-tile--translator {
  border-color: var(--info-border);
  background: color-mix(in srgb, var(--bg-surface) 88%, var(--info-bg));
}
.dashboard-tile--invitation {
  border-color: var(--warning-border);
  background: color-mix(in srgb, var(--bg-surface) 88%, var(--warning-bg));
}
.dashboard-tile.is-disabled,
.dashboard-tile.is-muted {
  border-color: var(--border-color);
  background: var(--neutral-bg);
}
.dashboard-tile.is-muted {
  opacity: 0.78;
}
.dashboard-tile:not(.is-disabled):hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--primary-color) 40%, var(--border-color));
  box-shadow: 0 12px 28px color-mix(in srgb, var(--text-main) 9%, transparent);
}
.dashboard-tile__link,
.dashboard-tile__body {
  box-sizing: border-box;
  display: flex;
  min-height: 124px;
  height: 100%;
  flex-direction: column;
  gap: 6px;
  padding: 16px 52px 16px 16px;
  color: inherit;
  text-decoration: none;
}
.dashboard-tile__link:focus-visible {
  outline: 3px solid var(--focus-ring-color);
  outline-offset: -3px;
}
.dashboard-tile__title {
  margin: 0;
  color: var(--text-main);
  font-size: 18px;
  line-height: 1.25;
}
.dashboard-tile__text {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}
.dashboard-tile__meta {
  width: fit-content;
  margin-top: auto;
}
.dashboard-tile__toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  opacity: 0;
}
.dashboard-tile:hover .dashboard-tile__toggle,
.dashboard-tile__toggle:focus-visible,
.dashboard-tile.is-muted .dashboard-tile__toggle {
  opacity: 1;
}
.dashboard-tile.is-disabled .dashboard-tile__toggle {
  opacity: 0;
  pointer-events: none;
}
@media (max-width: 760px) {
  .dashboard-tile__link,
  .dashboard-tile__body {
    min-height: 112px;
    padding: 15px 48px 15px 15px;
  }
}
.me-page {
  padding: 32px 0 56px;
}
.me-page-header {
  margin-top: 0;
}
.me-overview {
  display: grid;
  grid-template-columns: minmax(240px, 0.72fr) minmax(0, 2fr);
  gap: 14px;
  align-items: start;
  margin: 0 0 32px;
}
.me-role-card,
.me-now-card {
  box-sizing: border-box;
  min-width: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--text-main) 4%, transparent);
}
.me-role-card {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 128px;
  padding: 16px 62px 16px 18px;
}
.me-role-card__content {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.me-role-card__label {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
.me-role-card__value {
  overflow: hidden;
  color: var(--text-main);
  font-size: 24px;
  font-weight: 900;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-role-card__settings {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-surface) 92%, var(--primary-color));
  color: var(--text-muted);
  font-size: 17px;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--text-main) 6%, transparent);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}
.me-role-card__settings:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary-color) 45%, var(--border-color));
  background: color-mix(in srgb, var(--bg-surface) 82%, var(--primary-color));
  color: var(--primary-color);
  box-shadow: 0 10px 20px color-mix(in srgb, var(--text-main) 10%, transparent);
}
.me-role-card__settings:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary-color) 72%, transparent);
  outline-offset: 2px;
}
.me-now-card {
  padding: 18px;
}
.me-now-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.me-now-card__title {
  margin: 0;
  color: var(--text-main);
  font-size: 20px;
  line-height: 1.2;
}
.me-now-card__text,
.me-now-card__empty {
  margin: 5px 0 0;
  color: var(--text-secondary);
  line-height: 1.45;
}
.me-now-card__empty {
  padding: 12px 0 2px;
}
.me-now-list {
  display: grid;
  gap: 8px;
}
.me-now-item {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-surface) 94%, var(--neutral-bg));
  color: inherit;
  text-decoration: none;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    transform 0.16s ease;
}
.me-now-item:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary-color) 40%, var(--border-color));
  background: color-mix(in srgb, var(--bg-surface) 88%, var(--primary-color));
}
.me-now-item:focus-visible {
  outline: 3px solid var(--focus-ring-color);
  outline-offset: 2px;
}
.me-now-item--invitation {
  border-color: var(--warning-border);
  background: color-mix(in srgb, var(--bg-surface) 90%, var(--warning-bg));
}
.me-now-item--reading {
  border-color: var(--success-border);
  background: color-mix(in srgb, var(--bg-surface) 92%, var(--success-bg));
}
.me-now-item__copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}
.me-now-item__title {
  overflow: hidden;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-now-item__text {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-now-item__arrow {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
}
.me-section {
  margin-top: 30px;
}
.me-section + .me-section {
  margin-top: 34px;
}
.me-block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: stretch;
  gap: 14px;
}
@media (max-width: 900px) {
  .me-overview {
    grid-template-columns: 1fr;
  }
  .me-role-card {
    min-height: 104px;
  }
}
@media (max-width: 760px) {
  .me-page {
    padding-top: 20px;
  }
  .me-block-grid {
    grid-template-columns: 1fr;
  }
  .me-now-item {
    align-items: flex-start;
  }
  .me-now-item__title,
  .me-now-item__text {
    white-space: normal;
  }
}

/* H-web-07: the original NEwBOO dark palette, selected by OS preference.
   Source: backend/app/web/static/css/00-tokens.css :root[data-theme="dark"].
   This first no-script slice does not claim to implement a manual theme switch. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-main: #0b1120;
    --bg-surface: #111827;
    --bg-secondary: #172033;
    --text-main: #f8fafc;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #263348;
    --border-dark: #3b485f;
    --primary-color: #8b9cff;
    --action-primary-bg: #d8ffb0;
    --action-primary-bg-hover: #ecffd8;
    --action-primary-text: #102014;
    --book-card-bg: var(--bg-surface);
    --book-card-border: var(--border-color);
    --book-card-border-hover: var(--primary-color);
    --book-card-cover-bg: radial-gradient(circle at top, rgba(139, 156, 255, .22), transparent 42%), #263348;
    --book-card-cover-text: var(--text-muted);
    --book-card-title: var(--text-main);
    --book-card-meta: var(--text-muted);
    --book-card-shadow-hover: 0 12px 30px rgba(0, 0, 0, .24);
    --focus-ring-color: rgba(139, 156, 255, .38);
    --neutral-bg: #263348;
    --success-bg: #102a1c;
    --success-border: #14532d;
    --info-bg: #1e2a4a;
    --info-border: #314585;
    --warning-bg: #3a2b12;
    --warning-border: #854d0e;
    --surface: var(--bg-surface);
    --paper: var(--bg-main);
    --ink: var(--text-main);
    --line: var(--border-color);
  }
  .site-logo {
    background-image: url("/assets/brand/pandaolate-header-dark.png");
  }
  .site-footer__inner {
    background: linear-gradient(180deg, rgba(17, 24, 39, .8), transparent);
  }
  /* Legacy site.css still has a few green/white hardcoded components.
     Scope their overrides to real TOR pages, not unshipped features. */
  .auth-card,
  .library-card,
  .reader-piece,
  .reader-private__content,
  .chapter-toc__item,
  .account-error__card {
    border-color: var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
  }
  .auth-form label,
  .reader-private__content,
  .reader-piece__text,
  .chapter-toc__item {
    color: var(--text-main);
  }
  .auth-form input,
  .auth-card.author-card .auth-form input,
  .author-chapter-card .author-form textarea {
    border-color: var(--border-dark);
    background: var(--bg-surface);
    color: var(--text-main);
  }
  .auth-card__footer,
  .auth-card__footer a,
  .auth-form__help,
  .account-profile__hint,
  .library-heading > p:last-child,
  .library-card p:not(.eyebrow),
  .library-empty p,
  .reader-page__subtitle,
  .author-edit-warning,
  .book-card__meta {
    color: var(--text-muted);
  }
  .auth-card__footer a,
  .account-error__catalog,
  .reader-save-button,
  .reader-resume__link,
  .chapter-toc__item a {
    color: var(--primary-color);
  }
  .library-empty,
  .author-book-link,
  .author-release-preview,
  .chapter-toc__item--paid,
  .reader-markdown pre,
  .reader-resume,
  .reader-save-button,
  .account-profile__state {
    border-color: var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-main);
  }
  .author-book-link:hover,
  .reader-save-button:hover,
  .reader-piece:target {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
  }
  .account-error {
    background: radial-gradient(circle at 12% 10%, rgba(139,156,255,.13), transparent 44%), var(--bg-main);
  }
  .account-error__symbol {
    border-color: var(--warning-border);
    background: var(--warning-bg);
    color: #fde68a;
  }
  .account-error__message,
  .account-error__hint {
    color: var(--text-secondary);
  }
  .account-error__hint { border-top-color: var(--border-color); }
  .auth-form__error {
    border-color: #7f1d1d;
    border-left-color: #dc2626;
    background: #3f121a;
    color: #fecaca;
  }
}


/* H-web-08: NEwBOO home-spotlight-card and scrollable shelf. Source:
   backend/app/web/static/css/components/{home-surface,carousel,book-card}.css */
.home-spotlight-card {
  display: block; position: relative; min-height: 320px; overflow: hidden;
  border-radius: var(--radius-xl); color: #fff; text-decoration: none;
  background: radial-gradient(circle at 82% 38%, rgba(79,70,229,.44), transparent 38%),
    linear-gradient(135deg, #0f172a, #312e81 56%, #0f172a);
}
.home-spotlight-card__inner {
  display: grid; grid-template-columns: minmax(0,1fr) 190px;
  gap: 28px; align-items: center; min-height: 320px; padding: 32px 44px;
}
.home-spotlight-card__content { min-width: 0; }
.home-spotlight-card__eyebrow { display: inline-block; padding: 7px 12px;
  border-radius: 999px; background: rgba(255,255,255,.13);
  font-size: 13px; font-weight: 800; }
.home-spotlight-card__title { margin: 16px 0; font-size: clamp(28px,4vw,46px);
  line-height: 1.05; overflow-wrap: anywhere; color: #fff; }
.home-spotlight-card__text { margin: 0; color: #e2e8f0; }
.home-spotlight-card__cover-wrap { display: flex; justify-content: center; min-width: 0; }
.home-spotlight-card__cover { display: flex; width: 170px; aspect-ratio: 2/3;
  align-items: center; justify-content: center; border-radius: var(--radius-lg);
  background: rgba(255,255,255,.13); color: #e2e8f0; font-size: 14px;
  text-align: center; transform: rotate(3deg); box-shadow: 0 15px 35px rgba(0,0,0,.3); }
.home-shelf__track { display: flex; gap: 16px; padding: 2px 2px 16px;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
  scroll-snap-type: x proximity; }
.home-shelf__track .book-mini-card--shelf { flex: 0 0 180px; width: 180px;
  min-width: 180px; scroll-snap-align: start; }
@media (max-width: 640px) {
  .home-spotlight-card, .home-spotlight-card__inner { min-height: 260px; }
  .home-spotlight-card__inner { grid-template-columns: minmax(0,1fr) 104px;
    gap: 14px; padding: 20px; }
  .home-spotlight-card__cover { width: 100px; }
  .home-shelf__track .book-mini-card--shelf { flex-basis: 148px; width: 148px; min-width: 148px; }
}

/* H-web-09: NEwBOO source book-card.css uses fill-and-crop WebP covers. */
.book-mini-card__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
img.home-spotlight-card__cover {
  display: block;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

/* F-05: personal ranking follows NEwBOO's light/dark surface tokens. */
.ranking-panel { max-width: 900px; margin: 28px auto 72px; }
.ranking-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; margin: 24px 0; }
.ranking-pair__book { padding: 24px; border: 1px solid var(--border-color); background: var(--bg-surface); border-radius: var(--radius-lg); min-width: 0; }
.ranking-pair__title { overflow-wrap: anywhere; font-weight: 750; font-size: 21px; }
.ranking-pair__label { color: var(--text-muted); font-size: 13px; }
.ranking-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ranking-actions .ui-button { flex: 1 1 160px; }
.ranking-info { color: var(--text-secondary); margin-top: 16px; }
@media (max-width: 640px) { .ranking-pair { grid-template-columns: minmax(0,1fr); } .ranking-pair__book { padding: 18px; } }

/* F-05 personal ranks: tied items share one numbered place. */
.ranking-history { margin: 30px 0 64px; }
.ranking-history h2 { margin: 0 0 16px; }
.ranking-books { padding: 0; margin: 0; list-style: none; display: grid; gap: 10px; }
.ranking-book { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px 18px;
  min-width: 0; padding: 14px 18px; border: 1px solid var(--border-color);
  background: var(--bg-surface); border-radius: var(--radius-lg); }
.ranking-book a { overflow-wrap: anywhere; font-weight: 700; }
.ranking-book__place, .ranking-book__tie { color: var(--text-muted); font-size: 13px; }
.ranking-book__tie { border: 1px solid var(--border-color); padding: 2px 7px; border-radius: 20px; }
@media (max-width: 640px) { .ranking-book { padding: 12px 14px; } }

/* H-10: NEwBOO catalogue active filters, with one-click removal and mobile wrapping. */
.catalog-active-filters { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 10px 14px; margin: -7px 0 18px; }
.catalog-active-filters__label { padding-top: 7px; color: var(--text-muted); font-size: 13px; font-weight: 700; }
.catalog-active-filters__list { display: flex; flex: 1 1 250px; flex-wrap: wrap; gap: 8px; min-width: 0; }
.catalog-active-filters .ui-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 34px; padding: 6px 11px; border: 1px solid var(--border-dark); border-radius: 999px; background: var(--bg-surface); color: var(--text-main); font-size: 13px; line-height: 1.35; text-decoration: none; }
.catalog-active-filters .ui-chip:hover { border-color: var(--primary-color); }
.catalog-active-filters .ui-chip:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.catalog-active-filters .ui-chip__key { color: var(--text-muted); }
.catalog-active-filters .ui-chip__value { min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.catalog-active-filters .ui-chip__remove { flex: none; margin-left: 2px; font-size: 18px; line-height: 1; }
/* H-10: native NEwBOO taxonomy controls share the existing catalogue grid. */
.catalog-filters .ui-select { min-width: 0; max-width: 100%; text-overflow: ellipsis; }

/* H-10: restore original NEwBOO public BookCard text boundaries. */
.book-mini-card__body { min-width: 0; }
.book-mini-card__title {
  display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; line-clamp: 2;
}
.book-mini-card__meta {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.book-mini-card__cover { position: relative; }
/* H-11: original NEwBOO not_found/service_unavailable error layout. */
.not-found-page { padding: 40px 0 64px; }
.not-found-card { max-width: 680px; margin: 0 auto; padding: 40px; border: 1px solid var(--border-color); border-radius: var(--radius-xl); background: var(--bg-surface); text-align: center; }
.not-found-card__code { margin: 0 0 10px; color: var(--primary-color); font-size: 34px; line-height: 1; font-weight: 900; }
.not-found-card__title { margin: 0 0 12px; color: var(--text-main); font-size: 28px; line-height: 1.1; }
.not-found-card__text { max-width: 520px; margin: 0 auto; color: var(--text-muted); }
.not-found-card__actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.not-found-card__button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 14px; border-radius: var(--radius-sm); background: var(--text-main); color: var(--bg-surface); font-weight: 800; text-decoration: none; }
.not-found-card__button--ghost { background: var(--bg-surface); color: var(--text-main); border: 1px solid var(--border-dark); }
.not-found-card__button:focus-visible { outline: 3px solid var(--primary-color); outline-offset: 3px; }
@media (max-width: 560px) { .not-found-card { padding: 26px 18px; } }
/* H-11: internal public-book discovery, only for a missing book (404). */
.book-error-promos { max-width: 940px; margin: 28px auto 0; }
.book-error-promos h2 { margin: 0 0 14px; color: var(--text-main); font-size: 21px; }
.book-error-promos__grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.book-error-promos__card { display: flex; align-items: flex-start; gap: 12px; padding: 12px; min-width: 0; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--text-main); text-decoration: none; }
.book-error-promos__card:hover { border-color: var(--primary-color); }
.book-error-promos__card:focus-visible { outline: 3px solid var(--primary-color); outline-offset: 3px; }
.book-error-promos__cover { flex: 0 0 68px; width: 68px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); background: var(--book-card-cover-bg); }
.book-error-promos__cover--empty { display: grid; place-items: center; padding: 4px; color: var(--book-card-cover-text); font-size: 12px; text-align: center; }
.book-error-promos__body { display: block; min-width: 0; overflow-wrap: anywhere; }
.book-error-promos__title { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-height: 1.35; }
.book-error-promos__author { display: block; margin-top: 8px; color: var(--text-muted); font-size: 13px; }
@media (max-width: 640px) { .book-error-promos__grid { grid-template-columns: minmax(0,1fr); } .book-error-promos__card { min-height: 118px; } }

/* S019: visible book-registration action in both header layouts. */
.site-nav__create { white-space: nowrap; min-height: 40px; }
.site-mobile-nav__link--create { background: var(--primary-color); color: #fff; }
.site-mobile-nav__link--create:hover,.site-mobile-nav__link--create:focus-visible { color: #fff; background: var(--primary-color); filter: brightness(.9); }

/* H-10: horizontal NEwBOO spotlight from its home/index.html and
   home-surface.css, using real public books, without client-side scripts. */
.home-special-carousel { min-width: 0; }
.home-special-carousel__viewport {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: var(--radius-xl);
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.home-special-carousel__viewport:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 3px;
}
.home-special-carousel__track { display: flex; }
.home-special-carousel .home-spotlight-card {
  flex: 0 0 100%;
  min-width: 100%;
  height: 340px;
  min-height: 340px;
  scroll-snap-align: start;
  isolation: isolate;
  background:
    radial-gradient(circle at 82% 38%, color-mix(in srgb, var(--primary-color) 42%, transparent), transparent 34%),
    linear-gradient(135deg, #14152a, #34336b 52%, #14152a);
  box-shadow: 0 24px 70px color-mix(in srgb, var(--text-main) 18%, transparent);
}
.home-special-carousel .home-spotlight-card::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(15,23,42,.95), rgba(15,23,42,.82) 35%, rgba(15,23,42,.16));
}
.home-special-carousel .home-spotlight-card::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: -120px;
  right: -90px;
  width: 360px;
  height: 360px;
  pointer-events: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary-color) 35%, transparent);
  filter: blur(42px);
}
.home-special-carousel .home-spotlight-card__bg {
  position: absolute;
  z-index: 0;
  inset: -32px;
  width: calc(100% + 64px);
  height: calc(100% + 64px);
  object-fit: cover;
  filter: blur(24px) saturate(1.15);
  transform: scale(1.08);
  opacity: .5;
}
.home-special-carousel .home-spotlight-card__inner {
  position: relative;
  z-index: 3;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 34px;
  height: 100%;
  min-height: 0;
  padding: 38px 46px;
}
.home-special-carousel .home-spotlight-card__content {
  max-width: 680px;
  overflow: hidden;
}
.home-special-carousel .home-spotlight-card__title {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  font-size: clamp(26px, 4vw, 46px);
  line-height: 1.04;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.home-special-carousel .home-spotlight-card__text {
  display: -webkit-box;
  overflow: hidden;
  max-width: 430px;
  margin-top: 18px;
  color: #e2e8f0;
  font-size: 16px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.home-special-carousel .home-spotlight-card__cover { width: 190px; max-width: 100%; }
.home-special-carousel__hint {
  margin: 10px 2px 0;
  color: var(--text-muted);
  font-size: 12px;
}
@media (max-width: 640px) {
  .home-special-carousel .home-spotlight-card { height: 260px; min-height: 260px; }
  .home-special-carousel .home-spotlight-card__inner {
    grid-template-columns: minmax(0, 1fr) 100px;
    gap: 12px;
    padding: 20px;
  }
  .home-special-carousel .home-spotlight-card__cover { width: 100px; }
  .home-special-carousel .home-spotlight-card__text { margin-top: 12px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .home-special-carousel__viewport { scroll-behavior: auto; }
}

/* H-web-04: faithful public book hero from NEwBOO components/book-hero.css,
   components/book-section.css and pages/book-detail.css. No unsupported actions. */
.book-detail-page { padding: 32px 0 56px; }
.book-detail-page__container { display: flex; flex-direction: column; gap: 28px; }
.book-detail-page .breadcrumbs { display: flex; flex-wrap: wrap; gap: 10px; min-width: 0; color: var(--text-muted); }
.book-detail-page .breadcrumbs a { color: var(--primary-color); }
.book-hero-card {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  padding: 28px;
  border: 1px solid var(--border-color);
  border-radius: 28px;
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 18px 45px color-mix(in srgb, var(--text-main) 7%, transparent);
}
.book-hero-card__cover-col { display: flex; flex-direction: column; gap: 16px; }
.book-cover-xl {
  position: relative;
  display: flex;
  width: 100%;
  aspect-ratio: 2 / 3;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 22px;
  background: var(--book-card-cover-bg);
  color: var(--book-card-cover-text);
  font-weight: 800;
  text-align: center;
}
.book-hero-actions { display: flex; flex-direction: column; gap: 10px; }
.book-hero-actions .ui-button { width: 100%; min-height: 44px; text-align: center; }
.book-hero-actions .ui-button--ghost {
  border-color: color-mix(in srgb, var(--primary-color) 38%, var(--border-color));
  background: color-mix(in srgb, var(--primary-color) 7%, var(--bg-surface));
  color: var(--text-main);
}
.book-hero-card__body { min-width: 0; padding-top: 4px; }
.book-hero-card__kicker {
  margin: 0 0 12px;
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.book-hero-card__title {
  margin: 0;
  color: var(--text-main);
  font-size: clamp(32px, 4vw, 56px);
  font-weight: 950;
  line-height: .98;
  letter-spacing: -.06em;
  overflow-wrap: anywhere;
}
.book-hero-card__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 750;
}
.book-hero-card__credits { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 16px; color: var(--text-secondary); font-size: 14px; }
.book-hero-card__credit { display: inline-flex; gap: 6px; align-items: baseline; min-width: 0; overflow-wrap: anywhere; }
.book-hero-card__credit-label { color: var(--text-muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.book-hero-card__description {
  max-width: 760px;
  margin: 20px 0 0;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.book-section-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--text-main) 5%, transparent);
}
.book-section-card__kicker { margin: 0 0 6px; color: var(--primary-color); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.book-section-card__title { margin: 0 0 16px; color: var(--text-main); font-size: 24px; font-weight: 900; letter-spacing: -.035em; }
.book-detail-page .chapter-toc__list { min-width: 0; }
.book-detail-page .chapter-toc__item { min-width: 0; overflow-wrap: anywhere; }
.book-detail-page .chapter-toc__more { margin-top: 18px; }
@media (max-width: 760px) {
  .book-hero-card { grid-template-columns: minmax(0, 1fr); padding: 18px; gap: 20px; border-radius: 20px; }
  .book-hero-card__cover-col { width: min(220px, 100%); margin-inline: auto; }
  .book-hero-card__title { font-size: clamp(30px, 8vw, 44px); }
  .book-detail-page { padding: 20px 0 40px; }
  .book-section-card { padding: 14px; }
  .book-section-card__title { font-size: 22px; }
}

/* H-web-09: the book detail uses a real image in the existing cover slot. */
img.book-cover-xl { display: block; height: auto; object-fit: cover; }

/* F-05: NEwBOO book/translation star summary, never personal pairwise tiers. */
.book-rating-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
  max-width: 540px;
}
.book-rating-summary__item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  column-gap: 7px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: color-mix(in srgb, var(--primary-color) 5%, var(--bg-surface));
  min-width: 0;
}
.book-rating-summary__glyph { font-size: 24px; color: var(--primary-color); }
.book-rating-summary__name { font-size: 13px; font-weight: 800; }
.book-rating-summary__value { font-size: 22px; line-height: 1.15; }
.book-rating-summary__votes { color: var(--text-muted); font-size: 12px; }
.book-rating-summary__action {
  grid-column: 1 / -1;
  color: var(--primary-color);
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.book-score-forms { display: grid; gap: 18px; margin-block: 22px; }
.book-score-form fieldset {
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px;
  margin: 0 0 12px;
}
.book-score-form legend { font-weight: 850; padding-inline: 8px; }
.rating-picks { display: flex; flex-wrap: wrap; gap: 10px; }
.rating-pick { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
@media (max-width: 520px) {
  .book-rating-summary { grid-template-columns: minmax(0, 1fr); }
}


/* S035: keyboard-accessible multi-chapter form; price stays visible on mobile. */
.batch-purchase { max-width: 760px; }
.batch-purchase__form fieldset { border: 1px solid var(--border-color); border-radius: 14px; padding: 12px; margin: 14px 0; }
.batch-purchase__form legend { font-weight: 800; padding: 0 8px; }
.batch-purchase__row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border-color); cursor: pointer; min-height: 48px; }
.batch-purchase__row input { width: 18px; height: 18px; }
.batch-purchase__row span { min-width: 0; overflow-wrap: anywhere; }
.batch-purchase__row strong { white-space: nowrap; }
.batch-purchase__total { font-weight: 900; font-size: 22px; }
@media (max-width: 520px) { .batch-purchase__row { grid-template-columns: 22px minmax(0, 1fr); } .batch-purchase__row strong { grid-column: 2; } }

/* S020: explicitly linked books on the public book page, not recommendations. */
.book-related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.book-related-grid__item { min-width: 0; }
.book-related-grid__link { display: block; height: 100%; padding: 14px; border: 1px solid var(--border-color, #d9dee8); border-radius: 10px; color: var(--text-main); text-decoration: none; font-weight: 700; overflow-wrap: anywhere; }
.book-related-grid__link:hover, .book-related-grid__link:focus-visible { border-color: var(--primary-color); text-decoration: underline; }

/* Original NEwBOO discussion component, scoped to supported TOR features. */
/* Shared comments component. Page-specific reader themes may layer on top. */
.comments-block {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--text-main) 5%, transparent);
}

.comments-block__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.comments-block__kicker {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.comments-block__title {
  margin: 4px 0 0;
  color: var(--text-main);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
}

.comments-block__count {
  min-width: 30px;
  flex: 0 0 auto;
  justify-content: center;
}

.comments-form {
  display: grid;
  gap: 10px;
}

.comments-form__input {
  min-height: 92px;
}

.comments-form__submit {
  justify-self: start;
}

.comments-list {
  display: grid;
  gap: 12px;
}

.comments-block__empty {
  margin: 0;
  padding: 14px 16px;
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.comments-block__login {
  width: fit-content;
}

.comments-block__notice,
.comments-block__error {
  margin: 0;
}

.comment-card {
  position: relative;
  display: grid;
  gap: 9px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-main);
}

.comment-card--reply {
  background: var(--bg-surface);
}

.comment-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
  min-height: 28px;
}

.comment-card__author,
.comment-card__head strong {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
  text-decoration: none;
}

.comment-card__author:hover {
  text-decoration: underline;
}

.comment-card__date,
.comment-card__head span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.comment-card__body {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-card__footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  margin-top: 2px;
}

.comment-card__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-self: end;
  gap: 6px;
}

.comment-action-form,
.comment-card__report-form {
  display: inline-flex;
  margin: 0;
}

.comment-card__delete-form {
  position: absolute;
  top: 12px;
  right: 14px;
  display: inline-flex;
  margin: 0;
}

.comment-card--deletable {
  padding-right: 56px;
}

.comment-action {
  display: inline-flex;
  width: auto;
  min-width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--neutral-text);
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.comment-action:hover {
  border-color: var(--border-dark);
  background: var(--control-bg-hover);
  color: var(--text-main);
}

.comment-action:focus-visible,
.comments-form__tool:focus-visible,
.comment-spoiler__toggle:focus-visible {
  outline: 3px solid var(--focus-ring-color);
  outline-offset: 2px;
}

.comment-action--report {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
}

.comment-action--report:hover {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
}

.comment-action--delete {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
}

.comment-action--delete:hover {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
}

.comment-action--thanks,
.comment-action--thanks:hover,
.comment-action--thanks.is-sent {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.comment-action__icon {
  display: inline-flex;
  min-width: 14px;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.comment-action__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.comment-action__count {
  display: inline-flex;
  min-width: 14px;
  align-items: center;
  justify-content: center;
  color: currentColor;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.comment-action__count:empty {
  display: none;
}

.comment-reply {
  min-width: 0;
  margin: 0;
}

.comment-reply[open] {
  grid-column: 1 / -1;
}

.comment-reply__summary,
.comment-reply summary {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid var(--info-border);
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info-text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.comment-reply__summary::-webkit-details-marker,
.comment-reply summary::-webkit-details-marker {
  display: none;
}

.comment-reply__summary:hover,
.comment-reply summary:hover {
  border-color: var(--primary-color);
}

.comments-form--reply {
  margin-top: 8px;
}

.comments-replies {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  margin-left: 8px;
  padding-left: 14px;
  border-left: 2px solid var(--border-dark);
}

.comments-replies .comments-replies {
  margin-left: 0;
}

.comment-mention-suggestions {
  display: grid;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--text-main) 8%, transparent);
}

.comment-mention-suggestion {
  display: grid;
  gap: 2px;
  padding: 9px 11px;
  border: 0;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-main);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.comment-mention-suggestion:last-of-type {
  border-bottom: 0;
}

.comment-mention-suggestion span,
.comment-mention-suggestions__empty,
.comment-mention-suggestions__error {
  color: var(--text-muted);
  font-size: 13px;
}

.comment-mention-suggestion:hover,
.comment-mention-suggestion:focus-visible,
.comment-mention-suggestion.is-active {
  background: var(--bg-secondary);
  outline: none;
}

.comment-mention-suggestions__empty,
.comment-mention-suggestions__error {
  padding: 10px 11px;
}

.comments-form__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.comments-form__tool {
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.comments-form__tool:hover {
  border-color: var(--border-dark);
  color: var(--text-main);
}

.comment-spoiler {
  display: inline-block;
  max-width: 100%;
  align-items: baseline;
  gap: 5px;
  vertical-align: baseline;
}

.comment-spoiler__toggle {
  display: list-item;
  padding: 2px 7px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.9em;
  cursor: pointer;
}

.comment-spoiler__toggle:hover {
  border-color: var(--border-dark);
  color: var(--text-main);
}

.comment-spoiler__content {
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .comments-block {
    gap: 14px;
    padding: 16px;
    border-radius: var(--radius-xl);
  }

  .comments-form__submit {
    width: 100%;
    justify-self: stretch;
  }

  .comment-card {
    padding: 12px 13px;
    border-radius: var(--radius-lg);
  }

  .comment-card--deletable {
    padding-right: 48px;
  }

  .comment-card__delete-form {
    top: 10px;
    right: 10px;
  }

  .comment-action {
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
  }

  .comments-replies {
    margin-left: 2px;
    padding-left: 10px;
  }
}

/* E-08 messages are plain text, including literal links and line breaks. */
.mail-message-body { white-space: pre-wrap; overflow-wrap: anywhere; }

.mail-page .ui-button { white-space: normal; max-width: 100%; }

/* E-08: book cards only after B has checked public visibility. */
.mail-book-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  margin: 8px 0;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.mail-book-preview img { width: 48px; max-height: 68px; object-fit: cover; flex: none; }


/* Preserve line breaks in escaped, plain-text support responses. */
.support-message-body { white-space: pre-wrap; overflow-wrap: anywhere; }

.support-widget { --palette-white: #fff; --palette-black: #000; --support-accent: var(--primary-color); --error-text: #b91c1c; position: fixed; right: 24px; bottom: 24px; z-index: 900; }
.support-widget__trigger { min-height: 48px; padding: 0 20px; border: 0; border-radius: 999px; color: var(--palette-white); background: var(--color-accent, var(--support-accent)); box-shadow: 0 12px 32px color-mix(in srgb, var(--palette-black) 22%, transparent); cursor: pointer; font: inherit; font-weight: 700; }
.support-widget__panel { position: absolute; right: 0; bottom: 64px; display: grid; grid-template-rows: auto auto minmax(180px, 1fr) auto; width: min(390px, calc(100vw - 32px)); height: min(620px, calc(100vh - 120px)); overflow: hidden; border: 1px solid var(--border-color); border-radius: 20px; background: var(--bg-surface); color: var(--text-main); box-shadow: 0 24px 70px color-mix(in srgb, var(--palette-black) 25%, transparent); }
.support-widget__panel[hidden] { display: none; }
.support-widget__header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-color); }
.support-widget__title { margin: 0; font-size: 1.1rem; }
.support-widget__close { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 1.5rem; line-height: 1; }
.support-widget__notice { margin: 0; padding: 12px 20px; color: var(--text-muted); background: var(--bg-secondary); font-size: .82rem; line-height: 1.4; }
.support-widget__messages { overflow-y: auto; padding: 18px; }
.support-widget__message { display: flex; margin: 0 0 10px; }
.support-widget__message--own { justify-content: flex-end; }
.support-widget__message-body { max-width: 82%; padding: 10px 13px; border-radius: 15px; background: var(--bg-secondary); white-space: pre-wrap; overflow-wrap: anywhere; }
.support-widget__message--own .support-widget__message-body { color: var(--palette-white); background: var(--color-accent, var(--support-accent)); border-bottom-right-radius: 5px; }
.support-widget__message--support .support-widget__message-body { border-bottom-left-radius: 5px; }
.support-widget__form { padding: 14px; border-top: 1px solid var(--border-color); }
.support-widget__input { width: 100%; min-height: 76px; max-height: 150px; resize: vertical; }
.support-widget__form-row { display: flex; justify-content: flex-end; margin-top: 8px; }
.support-widget__error { margin: 8px 0 0; color: var(--error-text); font-size: .84rem; }
.support-widget__honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
@media (max-width:640px) {
.support-widget { right: 16px; bottom: 16px; }
  .support-widget__panel { position: fixed; inset: auto 0 0; width: 100%; height: min(76vh, 680px); border-radius: 22px 22px 0 0; }
}
@media (max-width:480px) {
  .support-widget {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .support-widget__trigger {
    width: 52px;
    min-height: 52px;
    padding: 0;
    border-radius: 18px;
    font-size: 0;
  }
  .support-widget__trigger::after {
    content: "Чат";
    font-size: 12px;
    line-height: 1;
  }
  /* Keep the fixed trigger out of the full-width auth CTA collision zone. */
  body:has(.auth-entry-section) .support-widget {
    top: calc(72px + env(safe-area-inset-top));
    bottom: auto;
  }
}

.support-widget .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.admin-support-message { margin: 12px 0; padding: 12px; border: 1px solid var(--border-color); border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-support-message.is-own { background: var(--bg-secondary); }

/* H-web-06: First public-reader visual slice from NEwBOO
   backend/app/web/static/css/pages/reader.css (main@17125ef7).
   Free-reader display settings are isolated from paid content. */
.reader-public {
  padding-block: 0 56px;
}
.reader-public .reader-width,
.reader-private .reader-width {
  width: min(100% - 28px, 860px);
  max-width: 860px;
  min-width: 0;
}
.reader-public .reader-topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(108px, auto) minmax(0, 1fr) minmax(108px, auto);
  gap: 12px;
  align-items: center;
  min-height: 66px;
  margin: 0 0 30px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: color-mix(in srgb, var(--bg-surface) 95%, transparent);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--text-main) 6%, transparent);
  backdrop-filter: blur(12px);
}
.reader-topbar__back {
  display: inline-flex;
  min-height: 44px;
  width: fit-content;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}
.reader-topbar__back:hover,
.reader-topbar__back:focus-visible {
  border-color: var(--primary-color);
  outline-offset: 3px;
}
.reader-topbar__title {
  display: grid;
  min-width: 0;
  gap: 3px;
  justify-items: center;
  text-align: center;
  line-height: 1.2;
}
.reader-topbar__book,
.reader-topbar__chapter {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reader-topbar__book {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 900;
}
.reader-topbar__chapter {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}
.reader-public .reader-page__header {
  display: grid;
  gap: 9px;
  margin: 0 0 30px;
  text-align: center;
}
.reader-public .reader-page__meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}
.reader-public .reader-page__title {
  margin: 0;
  color: var(--text-main);
  font-size: clamp(27px, 4vw, 38px);
  line-height: 1.18;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}
.reader-public .reader-page__subtitle {
  margin: 7px auto 0;
  max-width: 610px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}
.reader-public .chapter-content {
  padding: clamp(18px, 5vw, 38px);
  margin: 16px 0 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-main);
}
.reader-public .reader-markdown,
.reader-private .reader-piece__text {
  color: var(--text-main);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 2.3vw, 20px);
  line-height: 1.85;
  white-space: normal;
  overflow-wrap: anywhere;
}
.reader-page .reader-markdown p,
.reader-page .reader-piece__text p {
  line-height: 1.85;
}
.reader-page .reader-markdown a {
  color: var(--primary-color);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.reader-page .reader-markdown blockquote {
  border-left-color: var(--border-dark);
}
.reader-page .reader-markdown pre {
  max-width: 100%;
  overflow-x: auto;
  background: var(--bg-secondary);
}
.reader-page .chapter-navigation {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0;
}
.reader-page .chapter-navigation a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 8px 15px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
}
.reader-page .chapter-navigation a:hover,
.reader-page .chapter-navigation a:focus-visible {
  border-color: var(--primary-color);
}
.reader-page .reader-page__return {
  margin-top: 28px;
  text-align: center;
}
.reader-page .reader-page__return a,
.reader-private .reader-resume__link {
  color: var(--primary-color);
}
.reader-private .reader-save-button {
  border-color: var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-main);
}
.reader-private .reader-save-button:hover {
  border-color: var(--primary-color);
  background: var(--bg-surface);
}
.reader-private .reader-resume {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.reader-private .reader-piece:target {
  border-color: var(--primary-color);
  background: var(--bg-secondary);
}
@media (max-width: 640px) {
  .reader-public .reader-topbar {
    grid-template-columns: auto minmax(0, 1fr);
    min-height: 58px;
    gap: 8px;
    padding: 8px;
    margin-bottom: 22px;
  }
  .reader-public .reader-topbar__back {
    min-height: 42px;
    padding-inline: 10px;
  }
  .reader-public .reader-topbar__title {
    text-align: left;
    justify-items: start;
  }
  .reader-public .reader-page__header {
    margin-bottom: 20px;
  }
  .reader-public .chapter-content {
    padding: 18px 14px;
  }
  .reader-page .chapter-navigation a {
    flex: 1 1 135px;
    justify-content: center;
  }
}


/* H/S065: pinned paid-reader chrome follows NEwBOO's original reader
   topbar. No nonfunctional settings, TOC or next-version links. */
.reader-paid {
  padding-block: 0 56px;
}
/* The original NEwBOO reader has a viewport-wide sticky bar, not a
   narrow bar nested inside the 860px text column. Keep safe-area padding. */
.reader-paid .reader-topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: grid;
  box-sizing: border-box;
  width: 100%;
  grid-template-columns: minmax(120px, auto) minmax(0, 1fr) minmax(120px, auto);
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  margin: 0 0 24px;
  border: 0;
  border-bottom: 1px solid var(--border-color);
  border-radius: 0;
  background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--text-main) 6%, transparent);
  backdrop-filter: blur(14px);
}
.reader-paid .reader-topbar__title {
  min-width: 0;
  overflow: hidden;
}
.reader-paid .reader-topbar__book,
.reader-paid .reader-topbar__chapter {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reader-paid .reader-page__title {
  overflow-wrap: anywhere;
}
.reader-paid .reader-page__header {
  text-align: center;
  margin-bottom: 20px;
}
.reader-paid .reader-paid__content {
  padding: clamp(18px, 4vw, 36px);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  min-height: 140px;
}
.reader-paid .reader-piece {
  padding: 14px 0 20px;
  border-bottom: 1px solid var(--border-color);
  overflow-wrap: anywhere;
}
.reader-paid .reader-piece:last-child {
  border-bottom: 0;
}
/* Higher specificity than the inherited .reader-page .reader-markdown p
   rule: otherwise the spacing slider changes a variable but not the lines. */
.reader-paid .reader-piece__text.reader-markdown {
  margin: 0 0 14px;
  white-space: pre-wrap;
  font-family: var(--paid-font-family, Georgia, "Times New Roman", serif);
  font-size: var(--paid-font-size, clamp(17px, 2.3vw, 20px));
  line-height: var(--paid-line-height, 1.85);
}
/* Paid images follow NEwBOO's centered, bounded frame and caption.
   The only usable URL is a verified, temporary in-memory Blob. */
.reader-paid .reader-paid__image-block {
  margin: 24px auto;
  max-width: 100%;
}
.reader-paid .reader-paid__image-block .reader-content__image-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100px;
  max-height: 760px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}
.reader-paid .reader-paid__image-block .reader-content__image {
  display: block;
  max-width: 100%;
  max-height: 760px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.reader-paid .reader-paid__image-block .reader-content__image-caption {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: center;
  overflow-wrap: anywhere;
}
@media (max-width: 640px) {
  .reader-paid .reader-paid__image-block {
    margin: 18px auto;
  }
}

/* The save-position action must read as a button, never an underlined
   Markdown link. Match the 44px NEwBOO reader control minimum on touch. */
.reader-paid .reader-save-button {
  display: inline-flex;
  min-height: 44px;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease;
}
.reader-paid .reader-save-button:hover {
  border-color: var(--primary-color);
  background: var(--bg-surface);
}
.reader-paid .reader-save-button:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .reader-paid .reader-save-button {
    transition: none;
  }
}
.reader-paid .reader-resume {
  padding: 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-main);
  min-height: 38px;
}
@media (max-width: 640px) {
  .reader-paid .reader-topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
  }
  .reader-paid .reader-topbar__back-label {
    display: none;
  }
  .reader-paid .reader-topbar__back {
    min-width: 0;
    padding-inline: 10px;
  }
  .reader-paid .reader-topbar__title {
    justify-items: start;
    text-align: left;
  }
  .reader-paid .reader-paid__content {
    padding: 15px 12px;
  }
}


/* Reading preferences are applied only to this paid reader in memory.
   No plaintext, user preference or grant is saved in browser storage. */
.reader-paid .reader-width {
  width: min(calc(100% - 28px), var(--paid-reader-width, 860px));
  max-width: var(--paid-reader-width, 860px);
}
.reader-paid .reader-topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.reader-paid .reader-topbar__settings,
.reader-paid .reader-topbar__theme {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 800;
  cursor: pointer;
}
.reader-paid .reader-topbar__settings:focus-visible,
.reader-paid .reader-topbar__theme:focus-visible,
.reader-paid__settings button:focus-visible,
.reader-paid__settings input:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}
/* The original NEwBOO topbar has a separate one-tap theme control.
   Reuse the real 44px accessible action geometry in both color schemes. */
.reader-paid .reader-topbar__theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 23px;
  line-height: 1;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.reader-paid .reader-topbar__theme:hover,
.reader-paid .reader-topbar__settings:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-color);
}
/* Exact NEwBOO reader settings treatment: modal scrim and a right-anchored
   panel, not an inline form that pushes the paid text off the screen. */
.reader-paid .reader-paid__settings[hidden] {
  display: none !important;
}
.reader-paid .reader-paid__settings {
  position: fixed;
  inset: 0;
  z-index: 900;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.reader-paid .reader-paid__settings-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  /* The scrim must darken both light and dark themes.
     --text-main becomes white in dark mode and was washing the reader out. */
  background: color-mix(in srgb, #09101d 36%, transparent);
  cursor: pointer;
}
.reader-paid .reader-paid__settings-panel {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  box-sizing: border-box;
  display: grid;
  gap: 16px;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px - env(safe-area-inset-top));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 18px 48px color-mix(in srgb, var(--text-main) 26%, transparent);
}
.reader-paid__settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.reader-paid__settings-head h2 {
  margin: 0;
  font-size: 18px;
}
.reader-paid__settings-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}
.reader-paid__settings-field {
  display: grid;
  align-content: start;
  gap: 8px;
  font-weight: 650;
}
.reader-paid__settings input[type="range"] {
  width: 100%;
  accent-color: var(--primary-color);
}
.reader-paid__settings-panel button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-main);
  cursor: pointer;
}
.reader-paid__settings-panel button[aria-pressed="true"] {
  border-color: var(--primary-color);
  box-shadow: inset 0 0 0 1px var(--primary-color);
}
.reader-paid__settings-panel button[data-paid-settings-reset] {
  margin-top: 16px;
}
.reader-paid__themes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.reader-paid__settings-panel output {
  color: var(--text-muted);
  font-size: 13px;
}
body.reader-standalone[data-paid-reader-theme="light"] {
  color-scheme: light;
  --bg-main: #f7f7f8;
  --bg-surface: #fff;
  --bg-secondary: #f9fafb;
  --text-main: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --primary-color: #4f46e5;
}
body.reader-standalone[data-paid-reader-theme="dark"] {
  color-scheme: dark;
  --bg-main: #0b1120;
  --bg-surface: #111827;
  --bg-secondary: #172033;
  --text-main: #f8fafc;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --border-color: #263348;
  --primary-color: #8b9cff;
}
body.reader-standalone[data-paid-reader-theme="sepia"] {
  color-scheme: light;
  --bg-main: #efe5d3;
  --bg-surface: #fbf3e4;
  --bg-secondary: #f5e8d3;
  --text-main: #44301f;
  --text-secondary: #584633;
  --text-muted: #735d44;
  --border-color: #d5c5ab;
  --primary-color: #84582e;
}
@media (max-width: 640px) {
  .reader-paid .reader-paid__settings-panel {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    width: min(360px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px - env(safe-area-inset-top));
    padding: 16px;
  }
}


/* H/S065: server-authorized editions only; native <details> works without JS. */
.reader-paid .reader-topbar__toc {
  position: relative;
  min-width: 0;
}
.reader-paid .reader-topbar__toc > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  list-style: none;
}
.reader-paid .reader-topbar__toc > summary::-webkit-details-marker {
  display: none;
}
.reader-paid .reader-topbar__toc > summary:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}
.reader-paid .reader-paid__toc-menu {
  position: absolute;
  z-index: 120;
  top: calc(100% + 8px);
  right: 0;
  width: min(520px, calc(100vw - 24px));
  max-height: min(65dvh, 530px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 18px 40px color-mix(in srgb, var(--text-main) 18%, transparent);
}
.reader-paid .reader-paid__toc-head {
  display: grid;
  gap: 3px;
  padding: 16px 18px 11px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
.reader-paid .reader-paid__toc-head strong {
  color: var(--text-main);
  font-size: 16px;
}
.reader-paid .reader-paid__toc-head span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}
.reader-paid .reader-paid__toc-list {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 10px;
  list-style: none;
}
.reader-paid .reader-paid__toc-row {
  min-width: 0;
  border-radius: var(--radius-sm);
}
.reader-paid .reader-paid__toc-row--locked {
  background: color-mix(in srgb, var(--bg-secondary) 65%, transparent);
}
.reader-paid .reader-paid__toc-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  margin-top: 7px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.4;
  letter-spacing: .01em;
}
.reader-paid .reader-paid__toc-badge--owned {
  background: color-mix(in srgb, var(--primary-color) 13%, var(--bg-surface));
  color: var(--primary-color);
}
.reader-paid .reader-paid__toc-badge--free {
  background: color-mix(in srgb, #238659 14%, var(--bg-surface));
  color: var(--text-main);
}
.reader-paid .reader-paid__toc-badge--locked {
  background: color-mix(in srgb, var(--text-muted) 13%, var(--bg-surface));
  color: var(--text-muted);
}
.reader-paid .reader-paid__toc-title {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.reader-paid .reader-paid__toc-locked {
  cursor: not-allowed;
  opacity: .78;
}
.reader-paid .reader-paid__toc-list a:focus-visible .reader-paid__toc-title {
  text-decoration: underline;
}

.reader-paid .reader-paid__toc-list a,
.reader-paid .reader-paid__toc-list [aria-current="page"],
.reader-paid .reader-paid__toc-list .reader-paid__toc-locked {
  display: block;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  text-decoration: none;
}
.reader-paid .reader-paid__toc-list a:hover,
.reader-paid .reader-paid__toc-list a:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 1px;
  background: var(--bg-secondary);
}
.reader-paid .reader-paid__toc-list [aria-current="page"] {
  font-weight: 800;
  background: var(--bg-secondary);
  border-left: 3px solid var(--primary-color);
}
.reader-paid .reader-paid__toc-more {
  margin: 0;
  padding: 10px 14px 14px;
  color: var(--text-muted);
  line-height: 1.4;
}
.reader-paid .reader-paid__toc-more a {
  color: var(--primary-color);
}
@media (max-width: 640px) {
  .reader-paid .reader-topbar__toc > summary {
    min-width: 44px;
    padding: 8px;
    font-size: 0;
  }
  .reader-paid .reader-topbar__toc > summary::before {
    content: "≡";
    font-size: 23px;
    line-height: 1;
  }
  .reader-paid .reader-paid__toc-menu {
    position: fixed;
    top: 65px;
    left: 16px;
    right: 16px;
    width: auto;
    max-height: min(65dvh, 520px);
  }
}


/* H/S065: authentic NEwBOO prev/next reading cards.
   A closed neighbouring chapter has no href, even if its title is public. */
.reader-paid .reader-paid__chapter-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 10px;
  margin: -8px 0 20px;
}
.reader-paid .reader-paid__chapter-nav--bottom {
  grid-template-columns: minmax(0, 1fr) minmax(220px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  margin-bottom: 20px;
}
/* The original NEwBOO bottom row has a working TOC between both arrows. */
.reader-paid .reader-paid__chapter-nav--bottom .reader-topbar__toc {
  justify-self: center;
  min-width: 220px;
  width: 100%;
}
.reader-paid .reader-paid__chapter-nav--bottom .reader-topbar__toc > summary {
  min-height: 44px;
  width: 100%;
  justify-content: center;
  text-align: center;
  border-color: var(--text-main);
  border-radius: var(--radius-md);
  background: var(--text-main);
  color: var(--bg-surface);
  font-weight: 700;
}
.reader-paid .reader-paid__chapter-nav--bottom .reader-paid__nav-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 12px;
}
.reader-paid .reader-paid__chapter-nav--bottom .reader-paid__nav-name,
.reader-paid .reader-paid__chapter-nav--bottom .reader-paid__nav-badge {
  display: none;
}
.reader-paid .reader-paid__chapter-nav--bottom .reader-paid__nav-direction {
  font-size: 14px;
  color: inherit;
}
.reader-paid .reader-paid__chapter-nav--bottom .reader-paid__toc-menu {
  top: auto;
  bottom: calc(100% + 8px);
  right: 50%;
  transform: translateX(50%);
}
.reader-paid .reader-paid__nav-card {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 72px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.reader-paid .reader-paid__nav-card[data-paid-nav-next] {
  text-align: right;
  justify-items: end;
}
.reader-paid .reader-paid__nav-card--active:hover {
  border-color: var(--primary-color);
  background: var(--bg-secondary);
}
.reader-paid .reader-paid__nav-card--active:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 3px;
}
.reader-paid .reader-paid__nav-direction {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 850;
}
.reader-paid .reader-paid__nav-name {
  display: -webkit-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.reader-paid .reader-paid__nav-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-color);
}
.reader-paid .reader-paid__nav-card--locked,
.reader-paid .reader-paid__nav-card--disabled {
  background: color-mix(in srgb, var(--bg-secondary) 70%, var(--bg-surface));
  border-style: dashed;
  cursor: not-allowed;
}
.reader-paid .reader-paid__nav-card--locked .reader-paid__nav-badge,
.reader-paid .reader-paid__nav-card--disabled .reader-paid__nav-name {
  color: var(--text-muted);
}
@media (max-width: 640px) {
  .reader-paid .reader-paid__chapter-nav {
    gap: 8px;
    margin: 12px 0 22px;
  }
  .reader-paid .reader-paid__chapter-nav--bottom {
    grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  }
  .reader-paid .reader-paid__chapter-nav--bottom .reader-topbar__toc {
    min-width: 44px;
    width: 44px;
  }
  .reader-paid .reader-paid__chapter-nav--bottom .reader-topbar__toc > summary {
    min-width: 44px;
    min-height: 44px;
  }
  /* Keep the mobile lower TOC above its trigger, avoiding pointer capture. */
  .reader-paid .reader-paid__chapter-nav--bottom .reader-paid__toc-menu {
    position: absolute;
    top: auto;
    bottom: calc(100% + 8px);
    left: 50%;
    right: auto;
    width: min(360px, calc(100vw - 32px));
    max-height: min(42dvh, 360px);
    transform: translateX(-50%);
  }
  .reader-paid .reader-paid__nav-card {
    padding: 11px;
    min-height: 88px;
    gap: 5px;
  }
  .reader-paid .reader-paid__chapter-nav--bottom .reader-paid__nav-card {
    min-height: 44px;
    padding: 8px;
  }
  .reader-paid .reader-paid__nav-name {
    font-size: 13px;
  }
  .reader-paid .reader-paid__nav-direction,
  .reader-paid .reader-paid__nav-badge {
    font-size: 11px;
  }
}

/* Explain the public continuation boundary without inventing a paid entitlement. */
.reader-public .reader-next-state {
  margin: 18px 0;
  padding: 14px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/* Reader's confirmed wish for a next chapter, not a paid-access control. */
.reader-private .reader-continuation {
  margin: 20px 0;
  padding: 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-muted);
  line-height: 1.6;
}
.reader-private .reader-continuation h2 { color: var(--text-main); }

.reader-public .reader-width { width:min(calc(100% - 28px),var(--free-reader-width,860px));max-width:var(--free-reader-width,860px); }
.reader-public .free-reader-actions { display:none;justify-content:flex-end;gap:8px; }
.reader-public[data-free-settings-ready="1"] .free-reader-actions { display:flex; }
.reader-public .free-reader-actions button { min-width:44px;min-height:44px;border:1px solid var(--border-color);border-radius:var(--radius-sm);background:var(--bg-surface);color:var(--text-main);font:inherit;font-weight:800;cursor:pointer; }
.reader-public .reader-markdown { font-family:var(--free-font-family,Georgia,"Times New Roman",serif);font-size:calc(clamp(17px,2.3vw,20px)*var(--free-font-scale,1));line-height:var(--free-line-height,1.85); }
.reader-public .reader-markdown p { line-height:inherit; }
.reader-free-settings[hidden] { display:none!important; }
.reader-free-settings { position:fixed;inset:0;z-index:1500; }
.reader-free-settings__backdrop { position:absolute;inset:0;width:100%;border:0;background:rgba(9,16,29,.45);cursor:pointer; }
.reader-free-settings__panel { position:absolute;right:max(12px,env(safe-area-inset-right));top:max(12px,env(safe-area-inset-top));box-sizing:border-box;display:grid;gap:16px;width:min(360px,calc(100vw - 24px));max-height:calc(100dvh - 24px);padding:18px;overflow:auto;background:var(--bg-surface);color:var(--text-main);border:1px solid var(--border-color);border-radius:var(--radius-md);box-shadow:0 18px 48px rgba(0,0,0,.2); }
.reader-free-settings__head { display:flex;align-items:center;justify-content:space-between;gap:8px; }
.reader-free-settings__head h2 { margin:0;font-size:18px; }
.reader-free-settings__field { display:grid;gap:8px;min-width:0;font-size:14px;font-weight:650; }
.reader-free-settings__choices { display:flex;flex-wrap:wrap;gap:6px; }
.reader-free-settings__panel button { min-height:44px;padding:8px 10px;border:1px solid var(--border-color);border-radius:var(--radius-sm);background:var(--bg-secondary);color:var(--text-main);cursor:pointer; }
.reader-free-settings__panel button[aria-pressed="true"] { border-color:var(--primary-color);box-shadow:inset 0 0 0 1px var(--primary-color); }
.reader-free-settings__field input { width:100%;accent-color:var(--primary-color); }
.reader-free-settings__field output { font-size:13px;color:var(--text-muted); }
@media(max-width:640px){.reader-public .reader-topbar{grid-template-columns:auto minmax(0,1fr) auto}.reader-public .free-reader-actions{gap:4px}.reader-public .reader-markdown{font-size:calc(17px*var(--free-font-scale,1))}.reader-free-settings__panel{top:auto;right:0;bottom:0;width:100%;max-height:85dvh;border-radius:var(--radius-md) var(--radius-md) 0 0}}
:root[data-free-reader-theme="light"]{color-scheme:light;--bg-main:#f7f7f8;--bg-surface:#fff;--bg-secondary:#f9fafb;--text-main:#111827;--text-muted:#6b7280;--border-color:#e5e7eb;--primary-color:#4f46e5}
:root[data-free-reader-theme="dark"]{color-scheme:dark;--bg-main:#0b1120;--bg-surface:#111827;--bg-secondary:#172033;--text-main:#f8fafc;--text-muted:#9ca3af;--border-color:#263348;--primary-color:#8b9cff}
:root[data-free-reader-theme="sepia"]{color-scheme:light;--bg-main:#efe5d3;--bg-surface:#fbf3e4;--bg-secondary:#f5e8d3;--text-main:#44301f;--text-muted:#735d44;--border-color:#d5c5ab;--primary-color:#84582e}
:root[data-free-reader-theme] body{background:var(--bg-main);color:var(--text-main)}
:root[data-free-reader-theme] .reader-public .reader-markdown,:root[data-free-reader-theme] .reader-public .reader-markdown p{color:var(--text-main)}
:root[data-free-reader-theme="dark"] .site-logo{background-image:url("/assets/brand/pandaolate-header-dark.png")}
:root[data-free-reader-theme="light"] .site-logo,:root[data-free-reader-theme="sepia"] .site-logo{background-image:url("/assets/brand/pandaolate-header.png")}


/* H/S047: native, accessible free-reader TOC; public metadata only. */
.reader-public .reader-topbar__toc { position:relative; min-width:0; }
.reader-public .reader-free-toc__trigger {
  display:flex;align-items:center;justify-content:center;min-height:44px;
  padding:8px 12px;border:1px solid var(--border-color);border-radius:var(--radius-sm);
  background:var(--bg-surface);color:var(--text-main);font-size:13px;font-weight:800;
  cursor:pointer;list-style:none;
}
.reader-public .reader-free-toc__trigger::-webkit-details-marker { display:none; }
.reader-public .reader-free-toc__menu {
  position:absolute;top:calc(100% + 8px);right:0;z-index:85;
  box-sizing:border-box;width:min(410px,calc(100vw - 32px));max-height:min(68dvh,580px);
  padding:12px;overflow-y:auto;overscroll-behavior:contain;
  background:var(--bg-surface);border:1px solid var(--border-color);
  border-radius:var(--radius-md);box-shadow:0 16px 36px rgba(0,0,0,.18);
}
.reader-public .reader-free-toc__status { margin:0 0 8px;color:var(--text-muted);font-size:13px; }
.reader-public .reader-free-toc__list { list-style:none;margin:0;padding:0;display:grid;gap:4px; }
.reader-public .reader-free-toc__row {
  min-width:0;padding:9px;border-bottom:1px solid var(--border-color);
  font-size:14px;overflow-wrap:anywhere;
}
.reader-public .reader-free-toc__row > a,.reader-public .reader-free-toc__row > span {
  display:block;color:var(--text-main);font-weight:700;text-decoration:none;
}
.reader-public .reader-free-toc__row--current { background:var(--bg-secondary); }
.reader-public .reader-free-toc__row small {
  display:block;margin-top:3px;font-size:12px;color:var(--text-muted);
}
.reader-public .reader-free-toc__menu > a { display:block;margin-top:10px;font-size:13px; }
.reader-public .reader-free-toc__menu button { width:100%;margin-top:10px; }
.reader-public .reader-free-toc__menu button[hidden] { display:none; }
.reader-public .reader-free-toc__trigger:focus-visible,
.reader-public .reader-free-toc__menu a:focus-visible,
.reader-public .reader-free-toc__menu button:focus-visible {
  outline:3px solid var(--primary-color);outline-offset:2px;
}
/* Published text only; issue reports do not grant access or edit a chapter. */
.reader-public .reader-free-issues {
  box-sizing:border-box;margin:24px 0;padding:18px;
  border:1px solid var(--border-color);border-radius:var(--radius-md);
  background:var(--bg-surface);color:var(--text-main);
}
.reader-public .reader-free-issues > summary {
  cursor:pointer;font-size:16px;font-weight:800;min-height:44px;padding:10px 0;
}
.reader-public .reader-free-issues > p,
.reader-public .reader-free-issues > form { margin:12px 0;line-height:1.55; }
.reader-public .reader-free-issues__status,
.reader-public .reader-issues__feedback { color:var(--text-muted);font-size:14px; }
.reader-public .reader-free-issues form { display:grid;gap:13px; }
.reader-public .reader-free-issues label {
  display:grid;gap:6px;font-size:14px;font-weight:700;
}
.reader-public .reader-free-issues textarea,
.reader-public .reader-free-issues select {
  box-sizing:border-box;width:100%;max-width:100%;padding:10px 12px;
  border:1px solid var(--border-color);border-radius:var(--radius-sm);
  background:var(--bg-secondary);color:var(--text-main);font:inherit;
}
.reader-public .reader-free-issues textarea { min-height:84px;resize:vertical; }
.reader-public .reader-free-issues textarea[readonly] { min-height:64px; }
.reader-public .reader-free-issues button[type=submit] {
  min-height:44px;padding:10px 14px;border:0;border-radius:var(--radius-sm);
  background:var(--primary-color);color:white;font:inherit;font-weight:800;cursor:pointer;
}
.reader-public .reader-free-issues button[disabled] { opacity:.5;cursor:not-allowed; }
@media(max-width:640px) {
  .reader-public .reader-free-toc__trigger { min-width:44px;padding:8px;font-size:0; }
  .reader-public .reader-free-toc__trigger::before {
    content:"≡";font-size:22px;line-height:1;
  }
  .reader-public .reader-free-toc__menu {
    position:fixed;top:60px;left:16px;right:16px;width:auto;max-height:68dvh;
  }
  .reader-public .reader-free-issues { padding:14px; }
}


/* S011: public free-edition discussion below the reader. Never overlay text. */
.reader-public .reader-chapter-comments {
  box-sizing: border-box;
  margin: 26px 0;
  padding: clamp(14px, 3.5vw, 24px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
}
.reader-public .reader-chapter-comments .comments-block__head {
  margin-bottom: 16px;
}
.reader-public .reader-chapter-comments__form { display: grid; gap: 11px; }
.reader-public .reader-chapter-comments__form label { color: var(--text-main); font-weight: 750; }
.reader-public .reader-chapter-comments__form textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-height: 94px;
}
.reader-public .reader-chapter-comments__form button {
  min-height: 44px;
  width: fit-content;
}
.reader-public .reader-chapter-comments__anchor,
.reader-public .reader-chapter-comments__feedback,
.reader-public .reader-chapter-comments__reply-ref {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.reader-public .reader-chapter-comments .comments-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}
.reader-public .reader-chapter-comments .comment-card {
  min-width: 0;
  overflow-wrap: anywhere;
}
.reader-public .reader-chapter-comments__goto,
.reader-public .reader-chapter-comments__pagination a,
.reader-public .reader-chapter-comments__login a {
  color: var(--primary-color);
  text-underline-offset: 3px;
}
.reader-public .reader-chapter-comments .comment-reply { margin-top: 10px; }
.reader-public .reader-chapter-comments .comment-reply summary {
  min-height: 44px;
  cursor: pointer;
  padding-block: 9px;
}
.reader-public .reader-chapter-comments__source-highlight {
  background: color-mix(in srgb, var(--primary-color) 25%, transparent);
  transition: background 1.8s ease-out;
}
.reader-public .reader-chapter-comments__pagination { margin-block: 18px; }
@media(max-width:640px) {
  .reader-public .reader-chapter-comments { padding: 14px; }
  .reader-public .reader-chapter-comments__form button { width: 100%; }
}


/* A backdrop-filter creates a containing block for fixed descendants.
   Disable it only while the TOC overlay is open so the modal centers in the viewport. */
.reader-public .reader-topbar:has(.reader-free-toc[open]) {
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}

/* C-03 / H: reader-centered TOC. Keep metadata visible without granting paid access. */
.reader-public .reader-free-toc__backdrop {
  position:fixed;inset:0;z-index:1700;border:0;
  background:rgba(18,22,29,.45);cursor:pointer;
}
.reader-public .reader-free-toc__menu {
  position:fixed;inset:50% auto auto 50%;transform:translate(-50%,-50%);
  z-index:1701;display:flex;flex-direction:column;box-sizing:border-box;
  width:min(1140px,calc(100vw - 32px));height:min(740px,calc(100dvh - 32px));
  max-height:none;padding:0;overflow:hidden;border-radius:18px;
  background:var(--bg-surface);box-shadow:0 24px 70px rgba(0,0,0,.26);
}
.reader-public .reader-free-toc__head {
  display:flex;align-items:center;justify-content:space-between;
  gap:16px;padding:18px 24px;border-bottom:1px solid var(--border-color);
}
.reader-public .reader-free-toc__head > div { display:grid;gap:4px; }
.reader-public .reader-free-toc__head strong { font-size:20px; }
.reader-public .reader-free-toc__head small { font-size:13px;color:var(--text-muted); }
.reader-public .reader-free-toc__close {
  flex:none;min-width:44px;min-height:44px;border:0;border-radius:8px;
  background:transparent;color:var(--text-main);font-size:28px;cursor:pointer;
}
.reader-public .reader-free-toc__scroll {
  flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
  overscroll-behavior:contain;scrollbar-gutter:stable;
}
.reader-public .reader-free-toc__list {
  display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
  gap:4px 18px;padding:16px 22px 32px;align-items:start;
}
.reader-public .reader-free-toc__row {
  min-width:0;min-height:62px;box-sizing:border-box;
  border:0;border-radius:8px;padding:10px;
  overflow-wrap:anywhere;font-size:15px;
}
.reader-public .reader-free-toc__row--current {
  background:color-mix(in srgb,var(--primary-color) 13%,var(--bg-surface));
  outline:1px solid var(--primary-color);
}
.reader-public .reader-free-toc__row > a,
.reader-public .reader-free-toc__row > span {
  font-weight:500;line-height:1.4;text-decoration:none;
}
.reader-public .reader-free-toc__row--current > span { font-weight:750;color:var(--primary-color); }
.reader-public .reader-free-toc__row small { margin-top:5px;font-size:11px; }
.reader-public .reader-free-toc__status {
  flex:none;margin:0;padding:10px 24px;border-top:1px solid var(--border-color);
}
.reader-public .reader-free-toc__close:focus-visible,
.reader-public .reader-free-toc__scroll:focus-visible {
  outline:3px solid var(--primary-color);outline-offset:-3px;
}
@media (max-width:850px) {
  .reader-public .reader-free-toc__list { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:640px) {
  .reader-public .reader-free-toc__menu {
    inset:auto 0 0 0;transform:none;width:100%;height:min(88dvh,900px);
    border-radius:16px 16px 0 0;
  }
  .reader-public .reader-free-toc__head {padding:14px 16px;}
  .reader-public .reader-free-toc__list {
    grid-template-columns:minmax(0,1fr);padding:12px 12px 24px;gap:2px;
  }
  .reader-public .reader-free-toc__row { min-height:52px; }
}


/* Backdrop filters on sticky headers re-anchor fixed descendants.
   A paid TOC modal must be viewport-fixed, not header-fixed. */
.reader-paid .reader-topbar:has(.reader-topbar__toc[open]) {
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}

/* H paid TOC V2: server-scoped metadata in a centered, scrollable chapter grid. */
.reader-paid .reader-paid__toc-backdrop {
  position:fixed;inset:0;z-index:1799;border:0;
  background:rgba(18,22,29,.45);cursor:pointer;
}
.reader-paid .reader-topbar__toc .reader-paid__toc-menu,
.reader-paid .reader-paid__chapter-nav--bottom .reader-topbar__toc .reader-paid__toc-menu {
  position:fixed;top:50%;left:50%;right:auto;bottom:auto;
  transform:translate(-50%,-50%);z-index:1800;
  display:flex;flex-direction:column;box-sizing:border-box;
  width:min(1140px,calc(100vw - 32px));height:min(740px,calc(100dvh - 32px));
  max-height:none;overflow:hidden;border-radius:18px;
  background:var(--bg-surface);box-shadow:0 24px 70px rgba(0,0,0,.26);
}
.reader-paid .reader-paid__toc-head {
  display:flex;align-items:center;justify-content:space-between;
  gap:16px;padding:16px 24px;background:var(--bg-surface);
}
.reader-paid .reader-paid__toc-head > div { display:grid;gap:4px; }
.reader-paid .reader-paid__toc-head strong { font-size:20px; }
.reader-paid .reader-paid__toc-close {
  flex:none;min-width:44px;min-height:44px;border:0;border-radius:8px;
  background:transparent;color:var(--text-main);font-size:28px;cursor:pointer;
}
.reader-paid .reader-paid__toc-scroll {
  flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
  overscroll-behavior:contain;scrollbar-gutter:stable;
}
.reader-paid .reader-paid__toc-list {
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:6px 18px;padding:16px 22px 32px;align-items:start;
}
.reader-paid .reader-paid__toc-row {
  box-sizing:border-box;min-height:74px;padding:3px;
}
.reader-paid .reader-paid__toc-list a,
.reader-paid .reader-paid__toc-list [aria-current="page"],
.reader-paid .reader-paid__toc-list .reader-paid__toc-locked {
  padding:8px 10px;font-weight:500;
}
.reader-paid .reader-paid__toc-list [aria-current="page"] {
  font-weight:750;
  background:color-mix(in srgb,var(--primary-color) 13%,var(--bg-surface));
  outline:1px solid var(--primary-color);
}
.reader-paid .reader-paid__toc-more {
  flex:none;padding:10px 24px;border-top:1px solid var(--border-color);
}
.reader-paid .reader-paid__toc-close:focus-visible,
.reader-paid .reader-paid__toc-scroll:focus-visible {
  outline:3px solid var(--primary-color);outline-offset:-3px;
}
@media(max-width:850px) {
  .reader-paid .reader-paid__toc-list { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:640px) {
  .reader-paid .reader-topbar__toc .reader-paid__toc-menu,
  .reader-paid .reader-paid__chapter-nav--bottom .reader-topbar__toc .reader-paid__toc-menu {
    position:fixed;top:auto;bottom:0;left:0;right:0;transform:none;
    width:100%;height:min(88dvh,900px);max-height:none;border-radius:16px 16px 0 0;
  }
  .reader-paid .reader-paid__toc-head { padding:12px 16px; }
  .reader-paid .reader-paid__toc-list {
    grid-template-columns:minmax(0,1fr);gap:2px;padding:12px 12px 24px;
  }
  .reader-paid .reader-paid__toc-row { min-height:54px; }
}

/* Private finalized-delete archive TOC. Not the public reader's TOC. */
.archive-toc{display:inline-block;margin:10px 0 20px;position:relative;z-index:auto}
.archive-toc>summary{list-style:none;display:inline-flex;align-items:center;
  position:fixed;right:18px;bottom:18px;z-index:1750;
  box-shadow:0 8px 24px rgba(0,0,0,.18);
  cursor:pointer;padding:10px 16px;border-radius:9px;
  background:var(--bg-surface,#fff);color:var(--text-main,#252525);
  border:1px solid var(--border-color,#bbb);font-weight:650}
.archive-toc>summary::-webkit-details-marker{display:none}
.archive-toc>summary:focus-visible{outline:3px solid var(--primary-color,#3566ac);outline-offset:3px}
.archive-toc__backdrop{position:fixed;inset:0;z-index:1799;border:0;
  background:rgba(18,22,29,.45);cursor:pointer}
.archive-toc__dialog{position:fixed;left:50%;top:50%;right:auto;bottom:auto;
  transform:translate(-50%,-50%);z-index:1800;
  display:flex;flex-direction:column;box-sizing:border-box;
  width:min(1120px,calc(100vw - 32px));height:min(730px,calc(100dvh - 32px));
  overflow:hidden;border-radius:16px;
  background:var(--bg-surface,#fff);color:var(--text-main,#252525);
  border:1px solid var(--border-color,#ddd);box-shadow:0 24px 72px rgba(0,0,0,.26)}
.archive-toc__head{display:flex;align-items:center;justify-content:space-between;
  gap:16px;padding:18px 22px;border-bottom:1px solid var(--border-color,#ddd)}
.archive-toc__head>div{display:grid;gap:5px}
.archive-toc__head strong{font-size:20px}
.archive-toc__head span{font-size:13px;opacity:.7}
.archive-toc__close{flex:none;min-width:44px;min-height:44px;border:0;border-radius:8px;
  background:transparent;color:inherit;font-size:28px;cursor:pointer}
.archive-toc__scroll{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
  overscroll-behavior:contain;scrollbar-gutter:stable}
.archive-toc__list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px 18px;
  list-style:none;padding:16px 22px 30px;margin:0;align-items:start}
.archive-toc__row{min-width:0;display:grid;gap:7px;padding:10px;
  border-radius:9px;min-height:78px;border:1px solid transparent}
.archive-toc__row--current{background:color-mix(in srgb,var(--primary-color,#3566ac) 12%,transparent);
  border-color:var(--primary-color,#3566ac)}
.archive-toc__title{font-size:14px;line-height:1.45;font-weight:650;overflow-wrap:anywhere}
.archive-toc__choices{display:flex;flex-wrap:wrap;gap:5px 11px;font-size:12px;line-height:1.4}
.archive-toc__choices a{color:var(--primary-color,#3566ac);text-decoration:underline}
.archive-toc__choices a:focus-visible,.archive-toc__close:focus-visible,
.archive-toc__scroll:focus-visible{outline:3px solid var(--primary-color,#3566ac);outline-offset:1px}
.archive-toc__choices span{opacity:.75}
.archive-toc__foot{display:flex;gap:14px;flex-wrap:wrap;justify-content:space-between;
  border-top:1px solid var(--border-color,#ddd);padding:14px 22px}
.archive-toc__foot a{color:var(--primary-color,#3566ac);text-decoration:underline}
@media(max-width:850px){
 .archive-toc__list{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:640px){
 .archive-toc__dialog{left:0;right:0;top:auto;bottom:0;transform:none;
   border-radius:16px 16px 0 0;width:100%;height:min(88dvh,900px)}
 .archive-toc__head{padding:12px 14px}
 .archive-toc__list{grid-template-columns:minmax(0,1fr);padding:10px 12px 24px;gap:4px}
 .archive-toc__row{min-height:55px}
}

/* D-05: NEwBOO layers/public_detail.html + layer-storefront.css.
   Reuse Pandaolate design tokens and existing site navigation, no new theme. */
.layers-page { padding: 32px 0 64px; min-height: 60vh; }
.layers-page .ui-page-header { margin: 12px 0 28px; }
.layers-public-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 22px; align-items: start; }
.layer-panel { min-width: 0; border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 24px; background: var(--bg-surface); box-shadow: 0 8px 22px rgba(15,23,42,.035); }
.layer-panel h2 { margin: 0 0 12px; font-size: 22px; line-height: 1.25; }
.layer-storefront-books { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.layer-storefront-book { display: grid; grid-template-columns: 42px minmax(0,1fr); align-items: center; gap: 10px; min-height: 70px; padding: 9px 10px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-secondary); text-decoration: none; color: inherit; transition: border-color .18s ease, transform .18s ease; }
.layer-storefront-book:hover { border-color: var(--primary-color); transform: translateY(-1px); text-decoration: none; }
.layer-storefront-book__cover { display: flex; width: 40px; height: 52px; justify-content: center; align-items: center; overflow: hidden; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-surface); color: var(--text-muted); font-weight: 900; }
.layer-storefront-book__cover img { width: 100%; height: 100%; object-fit: cover; }
.layer-storefront-book__title { min-width: 0; overflow: hidden; color: var(--text-main); font-size: 14px; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; }
.layer-storefront-offer { position: sticky; top: 92px; }
.layer-offer { display: grid; gap: 10px; margin-bottom: 16px; }
.layer-offer__box { display: grid; gap: 8px; width: 100%; min-height: 120px; padding: 18px; border: 1px solid color-mix(in srgb, var(--primary-color) 28%, var(--border-color)); border-radius: var(--radius-lg); background: linear-gradient(135deg, color-mix(in srgb, var(--bg-surface) 88%, var(--primary-color)), var(--bg-surface)); color: inherit; text-align: left; text-decoration: none; }
.layer-offer__box--button { min-height: 52px; cursor: pointer; font: inherit; font-weight: 850; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.layer-offer__box--button:hover, .layer-offer__box--button:focus-visible { border-color: var(--primary-color); box-shadow: 0 14px 32px rgba(15,23,42,.12); transform: translateY(-1px); text-decoration: none; outline: none; }
.layer-offer__label { color: var(--primary-color); font-size: 13px; font-weight: 900; letter-spacing: .02em; }
.layer-offer__price { color: var(--text-main); font-size: 34px; line-height: 1.15; }
.layer-offer__meta { color: var(--text-muted); font-size: 14px; font-weight: 800; }
.layer-purchase-form { display: grid; gap: 14px; }
.layer-purchase-confirm { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.layer-purchase-confirm input { margin-top: 3px; width: 17px; height: 17px; flex: 0 0 17px; accent-color: var(--primary-color); }
.layer-note { color: var(--text-muted); font-size: 14px; line-height: 1.6; }
.layer-back { margin-top: 28px; color: var(--text-muted); }
.layer-back a { color: var(--primary-color); }
.layer-term-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.layer-term-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.layer-term-card h2 { margin: 0; }
.layer-term-card p { margin: 0; }
.layer-term-card__status { display: inline-flex; border: 1px solid var(--border-color); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--text-secondary); background: var(--bg-secondary); }
.layer-term-card__price { font-size: 20px; font-weight: 900; }
.layer-term-card .ui-button { margin-top: auto; }
.layer-error { max-width: 580px; margin: 20px auto; }
.layer-error h1 { font-size: clamp(26px,4vw,36px); }
.layer-error p { line-height: 1.6; margin-bottom: 24px; }
@media (max-width: 900px) {
  .layer-storefront-offer { position: static; }
  .layers-public-layout { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 640px) {
  .layers-page { padding: 18px 0 44px; }
  .layer-panel { padding: 16px; }
  .layer-storefront-books, .layer-term-grid { grid-template-columns: minmax(0,1fr); }
}

/* Original NEwBOO component: backend/app/web/static/css/components/book-cover-picker.css
   Identical source rules below; TOR currently offers one actual cover slot. */
.book-covers-form {
  gap: 24px;
}

.book-covers-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.book-cover-picker {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 10px;
  cursor: pointer;
}

.book-cover-picker__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.book-cover-picker__frame {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 0;
  aspect-ratio: 2 / 3;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px dashed color-mix(in srgb, var(--border-color) 72%, var(--text-muted));
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.book-cover-picker:hover .book-cover-picker__frame,
.book-cover-picker--selected .book-cover-picker__frame {
  border-color: color-mix(in srgb, var(--primary-color) 88%, var(--border-color));
  box-shadow: 0 14px 32px color-mix(in srgb, var(--text-main) 14%, transparent);
  transform: translateY(-1px);
}

.book-cover-picker__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-cover-picker__image[hidden],
.book-cover-picker__placeholder[hidden] {
  display: none;
}

.book-cover-picker__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.book-cover-picker__plus {
  display: flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary-color) 14%, var(--bg-surface));
  color: var(--primary-color);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.book-cover-picker__change {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-main) 86%, transparent);
  color: var(--bg-surface);
  font-size: 12px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.book-cover-picker:hover .book-cover-picker__change,
.book-cover-picker--selected .book-cover-picker__change {
  opacity: 1;
  transform: translateY(0);
}

.book-cover-picker__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.book-cover-picker__meta strong {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 900;
}

.book-cover-picker__meta small {
  min-height: 16px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-covers-actions {
  justify-content: flex-end;
}

@media (max-width: 980px) {
  .book-covers-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .book-covers-grid {
    grid-template-columns: 1fr;
  }
}

/* TOR H-web-11: one functional slot; do not create three decorative fake inputs. */
.book-covers-grid--single {
  grid-template-columns: minmax(0, 240px);
}
.book-cover-picker:focus-within .book-cover-picker__frame {
  outline: 3px solid var(--primary-color);
  outline-offset: 3px;
}
.book-cover-picker__error { color: var(--error-text, #b91c1c); font-size: 13px; }
.book-covers-form .book-covers-actions { display: flex; margin-top: 22px; }
@media (max-width: 560px) {
  .book-covers-grid--single { grid-template-columns: minmax(0, 1fr); max-width: 320px; }
}

/* Reference: book-settings.css and book-settings-panel.css (NEwBOO). */
.book-settings-page { padding: 28px 20px 56px; }
.book-settings-shell { width: min(1160px, 100%); margin: 0 auto; }
.book-settings-header { margin-bottom: 18px; }
.book-settings-card {
  padding: 22px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.book-settings-card--wide { max-width: 100%; }
.book-settings-card__head { margin-bottom: 18px; }
.book-settings-card__head h2 { margin: 0 0 6px; color: var(--text-main); font-size: 20px; }
.book-settings-card__head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}
.book-settings-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--border-color);
}
.book-settings-tabs a {
  padding: 11px 16px;
  border-bottom: 3px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}
.book-settings-tabs a[aria-current="page"] {
  border-color: var(--primary-color);
  color: var(--primary-color);
}
.book-covers-status { margin: 0 0 18px; color: var(--text-secondary); }
.book-covers-form .book-covers-actions .ui-button { min-height: 42px; }
@media (max-width: 640px) {
  .book-settings-page { padding: 20px 14px 42px; }
  .book-settings-card { padding: 18px; }
  .book-settings-header { flex-direction: column; }
  .book-settings-tabs a { flex: 1; text-align: center; }
  .book-covers-form .book-covers-actions .ui-button { width: 100%; }
}

/* TOR private account navigation, achievements and notifications. */
.account-layout { display:grid; grid-template-columns:238px minmax(0,1fr); gap:26px; align-items:start; }
.account-main { min-width:0; }
.account-sidebar { position:sticky; top:20px; min-width:0; padding:18px 12px 14px; border:1px solid var(--border-color); border-radius:var(--radius-lg); background:var(--bg-surface); }
.account-sidebar__header { padding:0 12px 14px; }
.account-sidebar__eyebrow { display:block; margin-bottom:4px; color:var(--text-muted); font-size:12px; font-weight:700; }
.account-sidebar__title { font-size:18px; color:var(--text-main); }
.account-sidebar .dashboard-nav { display:grid; gap:3px; min-height:0; margin:0; padding:0; overflow:visible; }
.account-sidebar .dashboard-nav__group-label { padding:8px 12px 5px; color:var(--text-muted); font-size:11px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.account-sidebar .dashboard-nav__item { display:flex; align-items:center; justify-content:flex-start; flex:initial; min-width:0; min-height:41px; height:auto; padding:9px 12px; border:0; border-radius:9px; background:transparent; color:var(--text-secondary); font-size:13px; font-weight:650; line-height:1.35; white-space:normal; overflow-wrap:anywhere; }
.account-sidebar .dashboard-nav__item:hover { background:var(--bg-secondary); color:var(--text-main); }
.account-sidebar .dashboard-nav__item.is-active { background:color-mix(in srgb,var(--primary-color) 10%,var(--bg-surface)); color:var(--primary-color); font-weight:800; }
.account-nav-group { margin-top:8px; padding-top:7px; border-top:1px solid var(--border-color); }
.account-nav-group summary { display:flex; align-items:center; justify-content:space-between; min-height:42px; gap:8px; padding:8px 12px; border-radius:9px; color:var(--text-secondary); cursor:pointer; font-size:13px; font-weight:750; list-style:none; }
.account-nav-group summary::-webkit-details-marker { display:none; }
.account-nav-group summary::after { content:"⌄"; font-size:18px; line-height:1; }
.account-nav-group[open] summary::after { transform:rotate(180deg); }
.account-nav-group summary:hover { background:var(--bg-secondary); }
.account-nav-group__items { display:grid; gap:2px; padding:3px 0 4px 8px; }
.account-sidebar__logout { margin:18px 8px 0; padding-top:14px; border-top:1px solid var(--border-color); }
.account-sidebar__logout .ui-button { width:100%; font-size:13px; }
.account-main .ui-page-header { margin-bottom:22px; }
.account-main .ui-section-header__title { font-size:22px; line-height:1.25; }
.account-main .me-block-grid { grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); }
.account-main .dashboard-tile { min-height:112px; }
.account-main .dashboard-tile__link { min-height:112px; padding-right:18px; }
.account-main .dashboard-tile__title { font-size:16px; }
.account-main .dashboard-tile__text { font-size:13px; }
.account-main .achievement-grid { grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); }
.achievement-card { display:flex; min-width:0; flex-direction:column; gap:9px; padding:17px 18px; border:1px solid var(--border-color); border-radius:var(--radius-lg); background:var(--bg-surface); }
.achievement-card.is-unlocked { border-color:#86caa2; background:color-mix(in srgb,var(--bg-surface) 94%,#bbf7d0); }
.achievement-card__top { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.achievement-card__icon { display:grid; width:34px; height:34px; place-items:center; border-radius:10px; background:var(--bg-secondary); color:var(--text-muted); font-size:18px; }
.is-unlocked .achievement-card__icon { background:#dcfce7; color:#166534; }
.achievement-card__status { color:var(--text-muted); font-size:11px; font-weight:750; }
.is-unlocked .achievement-card__status { color:#198754; }
.achievement-card__title { margin:0; font-size:16px; line-height:1.3; overflow-wrap:anywhere; }
.achievement-card__description { margin:0; color:var(--text-secondary); font-size:13px; line-height:1.5; }
.achievement-card__progress { display:grid; gap:8px; margin-top:auto; padding-top:7px; }
.achievement-card__progress-text { color:var(--text-muted); font-size:12px; }
.achievement-card progress { display:block; width:100%; height:8px; overflow:hidden; border:0; border-radius:99px; background:var(--border-color); }
.achievement-card progress::-webkit-progress-bar { border-radius:99px; background:var(--border-color); }
.achievement-card progress::-webkit-progress-value { border-radius:99px; background:var(--primary-color); }
.achievement-card progress::-moz-progress-bar { border-radius:99px; background:var(--primary-color); }
.achievement-card.is-unlocked progress::-webkit-progress-value { background:#15803d; }
.achievement-card.is-unlocked progress::-moz-progress-bar { background:#15803d; }
.achievement-card__date { margin:0; color:var(--text-muted); font-size:11px; }
.notifications-toolbar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin-bottom:20px; }
.notifications-tabs { display:flex; flex-wrap:wrap; gap:7px; min-width:0; }
.notifications-tab { display:inline-flex; min-height:38px; align-items:center; padding:8px 13px; border:1px solid var(--border-color); border-radius:9px; background:var(--bg-surface); color:var(--text-secondary); font-size:13px; font-weight:650; line-height:1.3; text-decoration:none; }
.notifications-tab:hover { border-color:var(--border-dark); background:var(--bg-secondary); }
.notifications-tab.is-active { background:var(--text-main); border-color:var(--text-main); color:var(--bg-surface); }
.notifications-read-all.is-empty { display:none; }
.notifications-feed { display:grid; gap:10px; min-width:0; }
.notification-card { display:flex; min-width:0; justify-content:space-between; align-items:center; gap:16px; padding:18px; border:1px solid var(--border-color); border-radius:var(--radius-md); background:var(--bg-surface); }
.notification-card__content { min-width:0; }
.notification-card__heading { display:flex; align-items:center; flex-wrap:wrap; gap:8px 12px; }
.notification-card__heading strong { font-size:15px; overflow-wrap:anywhere; }
.notification-card__content p { margin:8px 0; color:var(--text-secondary); font-size:14px; line-height:1.5; overflow-wrap:anywhere; }
.notification-card__content time { color:var(--text-muted); font-size:12px; overflow-wrap:anywhere; }
.notification-card__status { color:#9a4b15; font-size:11px; font-weight:750; }
.notification-card.is-read .notification-card__status { color:var(--text-muted); }
.notification-card__action { flex:0 0 auto; margin:0; }
.notifications-empty-state { padding:42px 20px; border:1px dashed var(--border-dark); border-radius:var(--radius-lg); background:var(--bg-surface); text-align:center; }
.notifications-empty-state strong { display:block; font-size:17px; }
.notifications-empty-state p { margin:7px 0 0; color:var(--text-muted); font-size:13px; line-height:1.5; }
.notifications-settings-card { margin-top:22px; overflow:hidden; border:1px solid var(--border-color); border-radius:var(--radius-lg); background:var(--bg-surface); }
.notifications-settings-card__summary { display:flex; align-items:center; padding:18px 20px; cursor:pointer; list-style:none; }
.notifications-settings-card__summary::-webkit-details-marker { display:none; }
.notifications-settings-card__summary::after { content:"⌄"; margin-left:auto; color:var(--text-muted); font-size:22px; line-height:1; }
.notifications-settings-card[open] > .notifications-settings-card__summary::after { transform:rotate(180deg); }
.notifications-settings-card__summary strong { display:block; font-size:16px; }
.notifications-settings-card__summary small { display:block; margin-top:4px; color:var(--text-muted); font-size:12px; line-height:1.5; }
.notifications-settings-card__body { padding:4px 20px 22px; }
.notifications-settings-card__saved { color:#15803d; font-size:13px; font-weight:750; }
.notifications-preferences-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.notifications-switch { display:flex; min-width:0; min-height:72px; gap:12px; align-items:flex-start; padding:13px; border:1px solid var(--border-color); border-radius:10px; background:var(--bg-secondary); cursor:pointer; }
.notifications-switch:hover { border-color:var(--border-dark); }
.notifications-switch__input { flex:0 0 18px; width:18px; height:18px; margin:2px 0 0; accent-color:var(--primary-color); }
.notifications-switch__text { display:grid; gap:5px; min-width:0; }
.notifications-switch__text strong { font-size:13px; font-weight:750; line-height:1.3; overflow-wrap:anywhere; }
.notifications-switch__text small { color:var(--text-muted); font-size:12px; line-height:1.5; overflow-wrap:anywhere; }
.notifications-settings-card__actions { display:flex; justify-content:flex-end; padding-top:18px; }
@media (max-width:1100px) {
  .account-layout { grid-template-columns:215px minmax(0,1fr); gap:18px; }
  .notifications-preferences-grid { grid-template-columns:minmax(0,1fr); }
}
@media (max-width:800px) {
  .account-layout { grid-template-columns:minmax(0,1fr); gap:16px; }
  .account-sidebar { position:static; padding:12px; }
  .account-sidebar__header { padding:3px 8px 7px; }
  .account-sidebar .dashboard-nav { grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px; }
  .account-sidebar .dashboard-nav__group-label { grid-column:1/-1; padding:4px 8px; }
  .account-sidebar .dashboard-nav__item { padding:9px; }
  .account-nav-group { grid-column:1/-1; margin-top:4px; }
  .account-nav-group__items { grid-template-columns:repeat(2,minmax(0,1fr)); gap:3px; }
  .account-sidebar__logout { margin:10px 0 0; padding-top:9px; }
  .account-sidebar__logout .ui-button { width:auto; }
}
@media (max-width:520px) {
  .notifications-toolbar { align-items:stretch; }
  .notifications-tabs { gap:6px; }
  .notifications-tab { font-size:12px; padding:7px 9px; }
  .notification-card { align-items:stretch; flex-direction:column; gap:12px; }
  .notification-card__action,.notification-card__action .ui-button { width:100%; }
  .notifications-settings-card__body { padding:4px 12px 16px; }
  .notifications-settings-card__summary { padding:14px 12px; }
  .notifications-preferences-grid { grid-template-columns:minmax(0,1fr); }
  .account-main .achievement-grid { grid-template-columns:minmax(0,1fr); }
}
