/* Book room: fog-white surfaces, cloth-bound books, one ink-blue reading card.
 * This visual layer reuses the shared radius/motion tokens and existing flows.
 */
:root {
  --library-ink: #17283c;
  --library-marine: #345c82;
  --library-mist: #e8eef4;
  --library-paper: #f5f7fa;
  --library-brass: #b49a6d;
  --library-display: 'Songti SC', 'STSong', 'Noto Serif CJK SC', SimSun, Georgia, serif;
  --bg: var(--library-paper);
  --bg-deep: var(--library-mist);
  --text: var(--library-ink);
  --text-secondary: #53677d;
  --text-tertiary: #61758a;
  --accent: var(--library-marine);
  --accent-press: var(--library-ink);
  --accent-soft: color-mix(in srgb, var(--library-marine) 9%, transparent);
  --border: color-mix(in srgb, var(--library-ink) 10%, transparent);
  --shadow-sm: 0 2px 8px rgba(23, 40, 60, .03);
  --shadow-md: 0 12px 32px rgba(23, 40, 60, .08);
}
[data-theme='dark'] {
  --bg: #0c0d10;
  --bg-deep: #1b232d;
  --surface: rgba(22, 29, 38, .82);
  --surface-strong: rgba(22, 29, 38, .94);
  --surface-solid: #161d26;
  --text: #eaf0f6;
  --text-secondary: #b2c0ce;
  --text-tertiary: #9caebf;
  --accent: #9abbd8;
  --accent-press: #b7d1e6;
  --accent-soft: rgba(154, 187, 216, .12);
  --border: rgba(190, 210, 230, .13);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .15);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, .24);
}

.navbar { border-bottom-color: transparent; height: 72px; }
.navbar__heading { display: flex; align-items: center; gap: 16px; min-width: 0; }
.navbar__title { font-size: 17px; letter-spacing: .02em; }
.navbar__caption { padding-left: 16px; border-left: 1px solid var(--border); color: var(--text-tertiary); font-size: 12px; }
.navbar__actions { gap: 12px; }
.btn--primary { background: var(--accent); box-shadow: none; }
[data-theme='dark'] .btn--primary { color: var(--library-ink); }
.btn--upload { font-size: 13px; padding-inline: 17px; }
.tabbar__brand-mark { background: var(--library-ink); box-shadow: none; }
.tabbar__brand-text { font-family: var(--library-display); font-weight: 600; letter-spacing: .06em; }
.tabbar__item { font-weight: 500; }
.tabbar__item.is-active { font-weight: 650; }

.library { display: flex; flex-direction: column; max-width: 1280px; padding: 32px 24px 128px; }
.library > * { min-width: 0; }
.hero, .library--populated > .hero { margin: 0 0 26px; padding: 0; max-width: none; }
.hero__intro { gap: 8px; margin-bottom: 14px; }
.hero__mark { width: 25px; height: 25px; border: 0; background: none; }
.hero__eyebrow { font-size: 11px; letter-spacing: .16em; font-weight: 500; }
.hero__title, .library--populated .hero__title {
  max-width: none; margin: 0 0 12px; font: 500 clamp(30px, 3.7vw, 43px)/1.35 var(--library-display); letter-spacing: -.025em;
}
.hero__title span { color: var(--text-secondary); }
.hero__subtitle, .library--populated .hero__subtitle { display: block; max-width: 580px; font-size: 13px; line-height: 1.8; }
.reading-flow { margin-top: 24px; max-width: 500px; }

/* The reader's current book is the visual anchor, not an advertising hero. */
.continue-reading {
  display: grid; grid-template-columns: minmax(0, 1fr) 104px; grid-template-rows: 1fr auto;
  gap: 20px 26px; margin-bottom: 18px; min-height: 264px; padding: 30px;
  color: #f5f7fa; background: var(--library-ink); border: 0; box-shadow: none; overflow: hidden; isolation: isolate;
}
.continue-reading__body { grid-column: 1; grid-row: 1; align-self: center; }
.continue-reading__eyebrow { color: #b9cbdc; font-size: 11px; letter-spacing: .08em; font-weight: 500; }
.continue-reading h2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font: 500 clamp(27px, 3.2vw, 40px)/1.4 var(--library-display); letter-spacing: .02em; margin: 10px 0 8px; }
.continue-reading__meta { color: #c1cfdd; font-size: 12px; line-height: 1.7; margin-bottom: 16px; }
.continue-reading__chapter { color: #c1cfdd; font-size: 12px; font-variant-numeric: tabular-nums; }
.continue-reading__tag { display: inline-flex; align-items: center; gap: 6px; color: #c1cfdd; font-size: 11px; }
.continue-reading__cover {
  position: relative; grid-column: 2; grid-row: 1 / -1; width: 104px; height: 152px; padding: 14px;
  align-self: center; justify-self: center; transform: rotate(6deg); font-size: 19px;
  border-left: 5px solid rgba(0, 0, 0, .2); box-shadow: 4px 3px 0 #dce3eb, 6px 5px 0 #7e8d9e, 0 16px 22px rgba(0, 0, 0, .2);
}
.continue-reading__cover::before { content: ''; position: absolute; inset: 9px; border: 1px solid rgba(255, 255, 255, .3); border-radius: calc(var(--radius-control) - 9px); pointer-events: none; }
.continue-reading > .btn { grid-column: 1; grid-row: 2; justify-self: start; min-height: 42px; padding: 10px 17px; gap: 20px; font-size: 12px; background: #f5f7fa; color: var(--library-ink); box-shadow: none; }
.continue-reading > .btn:focus-visible { outline-color: #b7d1e6; }
.continue-reading .book-card__progress { background: rgba(210, 225, 240, .18); max-width: 320px; height: 3px; }
.continue-reading .book-card__progress i { background: #b7d1e6; }
.continue-reading__position { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: #c1cfdd; margin-top: 9px; }

.library > .drop-zone, .library.library--populated > .drop-zone {
  min-height: 220px; padding: 24px; margin: 0; border: 1px dashed color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius-card); background: var(--surface-solid); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.drop-zone__icon, .library--populated .drop-zone__icon { display: grid; width: 42px; height: 42px; margin: 0 auto 12px; border-radius: var(--radius-control); background: var(--accent-soft); color: var(--accent); }
.drop-zone__icon svg { width: 21px; height: 21px; }
.drop-zone__eyebrow { margin-bottom: 8px; color: var(--text-secondary); font-size: 11px; letter-spacing: .08em; }
.drop-zone__main { font-size: 14px; font-weight: 500; line-height: 1.8; }
.drop-zone__link { font-weight: 650; white-space: nowrap; }
.drop-zone__hint { font-size: 11px; line-height: 1.7; color: var(--text-tertiary); margin-top: 10px; }
.drop-zone__formats { margin-top: 15px; }
.drop-zone__privacy { font-size: 10px; line-height: 1.65; }
.drop-zone.is-dragover { border-style: solid; background: var(--accent-soft); }
.upload-result { margin: 18px 0 0; }

.shelf-head, .library.library--populated > .shelf-head { margin: 32px 0 18px; gap: 16px; }
.shelf-head__label { flex-wrap: wrap; gap: 10px; }
.shelf-head__title { font-size: 20px; font-weight: 600; letter-spacing: .01em; }
.shelf-head__count { font-size: 12px; }
.shelf-search, .shelf-sort select { background: var(--surface-solid); min-height: 40px; }
.shelf-search { width: 200px; }
.shelf-sort select { font-size: 12px; }
.shelf-layout { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-solid); }
.shelf-layout button { display: grid; place-items: center; width: 33px; height: 32px; color: var(--text-tertiary); border-radius: calc(var(--radius-control) - 3px); }
.shelf-layout button[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent); }
.shelf-layout .selection-indicator { --radius-control: calc(var(--radius-sm) - 3px); }
.shelf-layout button:active { transform: scale(.96); }
.shelf-filters { padding: 0 0 14px; margin-bottom: 20px; gap: 6px; border-radius: 0; background: transparent; border-bottom: 1px solid var(--border); width: 100%; }
.shelf-filters button { padding: 7px 14px; font-size: 12px; min-height: 36px; }
.shelf-filters .selection-indicator { background: var(--accent-soft); }
.shelf-filters button[aria-pressed='true'] { color: var(--accent); }
.shelf-results { grid-column: 1 / -1; margin-bottom: 18px; }

.book-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 24px 20px; }
.book-card { min-width: 0; padding: 12px; gap: 14px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface-solid); }
.book-card__cover { min-width: 0; width: 100%; box-shadow: 0 5px 12px rgba(23, 40, 60, .12); border-radius: var(--radius-control); transition: transform var(--duration-fast) var(--ease); }
.book-card__cover::after { background: linear-gradient(100deg, rgba(255, 255, 255, .06), transparent 32%); }
.book-card__cover::before { border-color: rgba(255, 255, 255, .2); }
.book-card__cover-title { font-size: 19px; font-weight: 500; line-height: 1.6; letter-spacing: .06em; text-shadow: none; }
.book-card__cover-kicker { font-size: 7px; letter-spacing: .14em; }
.book-card__cover-seal { right: 17px; bottom: 17px; opacity: .8; }
.book-card__ribbon { background: var(--library-brass); height: 30px; width: 12px; }
.book-card__meta { padding: 0 2px 2px; min-width: 0; }
.book-card__name { display: block; width: 100%; text-align: left; font-weight: 600; font-size: 14px; }
.book-card__info { margin-top: 5px; font-size: 11px; line-height: 1.6; }
.book-card__recent { font-size: 10px; margin-top: 9px; }
.book-card__progress { height: 3px; }
.book-card__labels { display: flex; gap: 6px; align-items: center; margin-bottom: 7px; }
.book-card__format { display: inline-block; padding: 2px 5px; border-radius: var(--radius-xs); background: var(--accent-soft); color: var(--accent); font: 9px/1.4 ui-monospace, 'SFMono-Regular', Consolas, monospace; letter-spacing: .04em; }
.book-card__status { color: var(--text-tertiary); font-size: 10px; }
.book-card__remove { top: 18px; right: 18px; width: 28px; height: 28px; }

/* A compact, real list uses the same book controls and reading progress. */
.book-grid[data-layout='list'] { grid-template-columns: minmax(0, 1fr); gap: 10px; }
.book-grid[data-layout='list'] .book-card { display: grid; grid-template-columns: 62px minmax(0, 1fr); align-items: center; gap: 18px; padding: 14px 18px; }
.book-grid[data-layout='list'] .book-card__cover { width: 62px; height: 84px; padding: 10px; }
.book-grid[data-layout='list'] .book-card__cover-title { font-size: 12px; letter-spacing: .01em; line-height: 1.6; max-width: 100%; -webkit-line-clamp: 3; }
.book-grid[data-layout='list'] :is(.book-card__cover-kicker, .book-card__cover-seal, .book-card__ribbon) { display: none; }
.book-grid[data-layout='list'] .book-card__meta { padding-right: 32px; }
.book-grid[data-layout='list'] .book-card__name { font-size: 16px; }
.book-grid[data-layout='list'] .book-card__progress { max-width: 240px; }
.book-grid[data-layout='list'] .book-card__recent { margin-top: 6px; }
.book-grid[data-layout='list'] .book-card__remove { top: calc(50% - 16px); right: 18px; width: 32px; height: 32px; color: var(--text-tertiary); background: var(--bg); opacity: 1; transform: none; border: 1px solid var(--border); backdrop-filter: none; }

.page-main { padding-top: 30px; }
.forum-hero, .me-card, .board-card, .friend-card, .recommend-card, .stats-card, .post-detail { box-shadow: none; background: var(--surface-solid); }
.forum-hero__title, .login-title { font-family: var(--library-display); letter-spacing: .02em; font-weight: 500; }
.login-card { box-shadow: var(--shadow-md); }
.login-logo { background: var(--library-ink); box-shadow: none; }
.empty-state__art { color: var(--accent); background: var(--accent-soft); box-shadow: none; }

@media (hover: hover) and (pointer: fine) {
  .book-card:hover .book-card__cover { transform: translateY(-2px); box-shadow: 0 5px 12px rgba(23, 40, 60, .12); }
  .book-card__cover:active { transform: scale(.98); }
  .library > .drop-zone:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 3%, var(--surface-solid)); }
  .shelf-layout button:hover { color: var(--accent); }
}
@media (min-width: 1024px) {
  .view--library, .view--page { margin-left: 200px; }
  .tabbar { width: 200px; padding: 32px 16px 28px; background: color-mix(in srgb, var(--surface-solid) 76%, var(--bg)); border-right: 1px solid var(--border); }
  .tabbar__brand { padding: 0 8px; gap: 10px; margin-bottom: 44px; }
  .tabbar__brand-text { font-size: 24px; }
  .tabbar__brand-mark { width: 34px; height: 34px; }
  .tabbar__item { min-height: 46px; font-size: 13px; gap: 12px; }
  .tabbar__item svg { width: 18px; height: 18px; }
  .tabbar__foot { display: flex; flex-direction: column; gap: 18px; padding: 24px 8px 0; font-size: 10px; letter-spacing: .04em; font-weight: 400; }
  .tabbar__foot-title { color: var(--text-secondary); font: 500 20px/1.65 var(--library-display); letter-spacing: .06em; }
  .navbar { padding-inline: clamp(28px, 4vw, 60px); }
  .library, .library.library--populated { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); gap: 0 22px; padding: 34px clamp(28px, 4vw, 60px) 72px; }
  .library > .hero { grid-column: 1; align-self: center; margin: 0 0 26px; }
  .library > .drop-zone { grid-column: 2; grid-row: auto; align-self: stretch; margin: 0 0 18px; }
  .library.library--populated > .drop-zone { margin-bottom: 18px; }
  .library.library--resumable > .hero { grid-column: 1 / -1; }
  .library.library--resumable > .continue-reading { grid-column: 1; }
  .library > :is(.shelf-head, .shelf-filters, .book-grid, .empty-state, .library-status, .upload-result) { grid-column: 1 / -1; }
  .shelf-head, .library.library--populated > .shelf-head { margin-top: 24px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 22px 18px; }
  .page-main { max-width: 1120px; padding-inline: clamp(28px, 4vw, 60px); }
}
@media (max-width: 1023px) {
  .library > .drop-zone, .library.library--populated > .drop-zone { min-height: 150px; padding: 18px 20px; }
  .library--populated > .drop-zone { display: grid; grid-template-columns: 42px minmax(0, 1fr); text-align: left; column-gap: 16px; }
  .library--populated .drop-zone__icon { grid-column: 1; grid-row: 1 / 4; margin: 0; align-self: center; }
  .library--populated :is(.drop-zone__eyebrow, .drop-zone__main, .drop-zone__hint) { grid-column: 2; }
  .library--populated .drop-zone__main br { display: none; }
  .library--populated .drop-zone__main { font-size: 13px; }
  .library--populated .drop-zone__hint { margin-top: 5px; font-size: 10px; }
  .library--populated .upload-progress { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .navbar { height: 64px; padding-inline: 18px; }
  .navbar__caption { display: none; }
  .navbar__actions { gap: 8px; }
  .btn--upload { padding-inline: 12px; min-height: 40px; }
  .library, .library.library--populated { padding: 26px 18px 120px; }
  .hero, .library--populated > .hero { margin-bottom: 22px; }
  .hero__intro { margin-bottom: 10px; }
  .hero__title, .library--populated .hero__title { font-size: clamp(26px, 7.5vw, 34px); line-height: 1.5; max-width: none; }
  .hero__title span { display: block; }
  .hero__subtitle, .library--populated .hero__subtitle { font-size: 12px; line-height: 1.8; }
  /* Returning readers see their shelf sooner; the roomy welcome stays for empty shelves. */
  .library--populated .hero__title { font-size: clamp(20px, 5.8vw, 24px); line-height: 1.4; margin-bottom: 0; }
  .library--populated .hero__title span { display: inline; }
  .library--populated .hero__subtitle { display: none; }
  .library.library--populated > .drop-zone { grid-template-columns: 32px minmax(0, 1fr); gap: 0 12px; min-height: 108px; padding: 16px; }
  .library--populated .drop-zone__eyebrow { display: none; }
  .library--populated .drop-zone__icon { width: 32px; height: 32px; }
  .continue-reading { grid-template-columns: minmax(0, 1fr) 78px; gap: 18px; padding: 24px 22px; min-height: 236px; }
  .continue-reading__cover { width: 76px; height: 114px; padding: 11px; font-size: 15px; }
  .continue-reading h2 { font-size: 28px; line-height: 1.45; letter-spacing: 0; }
  .continue-reading__meta { font-size: 10px; margin-bottom: 12px; }
  .continue-reading > .btn { grid-column: 1; width: auto; font-size: 11px; min-height: 38px; padding: 9px 12px; gap: 12px; }
  .shelf-head, .library.library--populated > .shelf-head { margin-top: 28px; margin-bottom: 14px; }
  .shelf-head__label { align-items: baseline; justify-content: space-between; width: 100%; }
  .shelf-head__title { font-size: 19px; }
  .shelf-head__count { font-size: 11px; }
  .shelf-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; width: 100%; gap: 7px; }
  .shelf-search { width: auto; min-width: 0; padding-inline: 9px; }
  .shelf-search input { font-size: 16px; }
  .shelf-sort select { max-width: 100px; padding: 0 18px 0 8px; font-size: 11px; }
  .shelf-layout button { width: 44px; height: 44px; }
  .shelf-filters { margin-bottom: 18px; padding-bottom: 12px; gap: 2px; }
  .shelf-filters button { min-height: 36px; padding-inline: 4px; font-size: 11px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
  .book-card { padding: 9px; gap: 12px; }
  .book-card__cover { padding: 13px; }
  .book-card__cover-title { font-size: 16px; letter-spacing: .025em; }
  .book-card__cover-kicker { top: 16px; font-size: 6px; }
  .book-card__name { font-size: 12px; }
  .book-card__info { font-size: 10px; }
  .book-card__recent { font-size: 9px; }
  .book-card__cover-seal { right: 13px; bottom: 13px; width: 20px; height: 20px; }
  .book-card__remove { top: 14px; right: 14px; }
  .book-grid[data-layout='list'] .book-card { padding: 12px; gap: 14px; }
  .book-grid[data-layout='list'] .book-card__name { font-size: 14px; }
  .book-grid[data-layout='list'] .book-card__remove { right: 12px; }
  .page-main { padding-inline: 18px; }
}
@media (max-width: 480px) {
  /* Search gets its own row so text and the clear control remain usable. */
  .shelf-tools { grid-template-columns: minmax(0, 1fr) auto; }
  .shelf-search { grid-column: 1 / -1; min-height: 44px; }
  .shelf-sort { grid-column: 1; }
  .shelf-sort select { width: 150px; max-width: 100%; }
  .shelf-layout { grid-column: 2; justify-self: end; }
}
@media (prefers-reduced-motion: reduce) {
  .book-card__cover, .shelf-layout button { transition: none; }
  .book-card:hover .book-card__cover, .book-card__cover:active, .shelf-layout button:active { transform: none; }
}
@media (pointer: coarse) {
  .shelf-layout button { min-width: 44px; min-height: 44px; }
  .book-grid[data-layout='list'] .book-card__remove { width: 44px; height: 44px; top: calc(50% - 22px); }
  .book-grid[data-layout='list'] .book-card__meta { padding-right: 44px; }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .navbar, .tabbar { background: var(--surface-solid); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
