/* ==========================================================================
   Bookly — дизайн-система (редизайн v2). Токены из design_handoff.
   Свет/тёмная тема через класс .dark на <html>.
   ========================================================================== */
:root {
  --bg: #f9fafb; --surface: #ffffff; --surface-2: #f3f4f6;
  --ink: #111827; --ink-soft: #4b5563; --ink-faint: #9ca3af;
  --line: #e9ebef; --line-strong: #e5e7eb;
  --indigo: #6366f1; --indigo-strong: #4f46e5; --indigo-soft: #eef2ff;
  --star: #f59e0b;
  --shadow-card: 0 1px 2px rgba(17,24,39,.04), 0 8px 24px -12px rgba(17,24,39,.12);
  --shadow-hover: 0 8px 18px -6px rgba(79,70,229,.18), 0 24px 44px -20px rgba(17,24,39,.28);
  --font-sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
html.dark {
  --bg: #1d1d1f; --surface: #28282a; --surface-2: #303032;
  --ink: #f4f4f6; --ink-soft: #a4a4a6; --ink-faint: #7f7f81;
  --line: #3a3a3c; --line-strong: #434345;
  --indigo: #818cf8; --indigo-strong: #6366f1; --indigo-soft: rgba(129,140,248,.14);
  --star: #fbbf24;
  --shadow-card: 0 2px 4px rgba(0,0,0,.28), 0 12px 28px -14px rgba(0,0,0,.5);
  --shadow-hover: 0 10px 22px -8px rgba(0,0,0,.5), 0 28px 50px -22px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }
input, textarea { font-family: inherit; }
::selection { background: var(--indigo); color: #fff; }
input:focus, button:focus { outline: none; }
.bk-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.bk-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 20px; }
.hidden { display: none !important; }
html.modal-open, body.modal-open { overflow: hidden; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.tnum { font-variant-numeric: tabular-nums; }

@keyframes bkxIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes bkxPop { from { opacity: 0; transform: translateY(20px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes bkxOverlay { from { opacity: 0; } to { opacity: 1; } }
@keyframes bkxSpin { to { transform: rotate(360deg); } }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--indigo); animation: bkxSpin .8s linear infinite; }

/* ---------- NAV ---------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 3px rgba(17,24,39,.04);
}
.nav-inner { height: 60px; display: flex; align-items: center; gap: 30px; }
.logo { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.logo i { color: var(--indigo); font-size: 22px; }
.logo span { font-size: 21px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.nav-links { display: flex; gap: 4px; margin-left: 6px; }
.nav-link { cursor: pointer; padding: 8px 13px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--ink-soft); background: transparent; transition: all .16s ease; border: none; }
.nav-link:hover { color: var(--ink); }
.nav-link.active { font-weight: 600; color: var(--ink); background: var(--surface-2); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.icon-btn { position: relative; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--surface-2); color: var(--ink-soft); cursor: pointer; font-size: 14px; transition: all .16s ease; }
.icon-btn:hover { background: color-mix(in srgb, var(--indigo) 12%, var(--surface-2)); color: var(--ink); }
.icon-btn .badge { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.profile-pill { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 5px; border-radius: 22px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; }
.profile-pill .ava { width: 28px; height: 28px; border-radius: 50%; background: var(--indigo); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; overflow: hidden; }
.profile-pill .ava img { width: 100%; height: 100%; object-fit: cover; }
.profile-pill .pname { font-size: 13.5px; color: var(--ink); font-weight: 500; }
.plan-tag { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; color: var(--indigo); background: var(--indigo-soft); border-radius: 5px; padding: 2px 6px; text-transform: uppercase; }
.btn-login { padding: 8px 18px; border-radius: 10px; border: none; background: var(--indigo); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; }
.btn-login:hover { background: var(--indigo-strong); }

/* ---------- HERO ---------- */
.hero { padding: 64px 0 40px; text-align: center; }
.hero-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 20px; background: var(--indigo-soft); color: var(--indigo-strong); font-size: 12.5px; font-weight: 600; margin-bottom: 22px; }
.hero h1 { font-size: 48px; line-height: 1.08; letter-spacing: -.025em; font-weight: 800; color: var(--ink); margin: 0 auto 18px; max-width: 820px; text-wrap: balance; }
.hero p { font-size: 19px; color: var(--ink-soft); margin: 0 auto 32px; max-width: 540px; }
.search-box { max-width: 540px; margin: 0 auto; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 14px; padding: 6px 6px 6px 18px; box-shadow: var(--shadow-card); }
.search-box i { color: var(--ink-faint); font-size: 14px; }
.search-box input { flex: 1; border: none; background: transparent; color: var(--ink); font-size: 15px; padding: 11px 4px; }
.search-box .find { padding: 11px 22px; border: none; border-radius: 10px; background: var(--indigo); color: #fff; font-weight: 600; font-size: 14.5px; cursor: pointer; transition: background .16s ease; }
.search-box .find:hover { background: var(--indigo-strong); }

/* ---------- GENRE CHIPS ---------- */
.genres-row { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; align-items: center; padding: 12px 0 4px; }
.fav-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all .16s ease; flex-shrink: 0; }
.fav-btn.active { border-color: var(--indigo); background: var(--indigo); color: #fff; }
.chip { padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all .16s ease; white-space: nowrap; }
.chip:hover { border-color: color-mix(in srgb, var(--indigo) 45%, var(--line-strong)); }
.chip.active { background: var(--indigo); color: #fff; border-color: var(--indigo); }

/* ---------- SECTION HEADER + SORT ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.section-head h2 { font-size: 24px; font-weight: 700; color: var(--ink); margin: 0; letter-spacing: -.01em; }
.dropdown { position: relative; }
.dd-btn { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink-soft); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.dd-btn .fa-chevron-down { font-size: 10px; }
.dd-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 190px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-hover); overflow: hidden; padding: 5px; }
.dd-menu.left { left: 0; right: auto; width: 220px; max-height: 300px; overflow-y: auto; }
.dd-item { display: flex; align-items: center; justify-content: space-between; width: 100%; text-align: left; padding: 9px 12px; border: none; border-radius: 8px; background: transparent; color: var(--ink-soft); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.dd-item.active { background: var(--indigo-soft); color: var(--ink); font-weight: 600; }
.dd-item i { font-size: 11px; color: var(--indigo); opacity: 0; }
.dd-item.active i { opacity: 1; }

/* ---------- BOOK GRID + POSTER CARD ---------- */
.book-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 22px; }
.book-card { position: relative; aspect-ratio: 2/3; border-radius: 15px; overflow: hidden; border: 1px solid var(--line-strong); box-shadow: var(--shadow-card); cursor: pointer; transition: transform .25s ease, box-shadow .25s ease; }
.book-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }
.book-card .ph { position: absolute; top: 34%; left: 50%; transform: translate(-50%,-50%); font-size: 40px; color: rgba(255,255,255,.22); }
.book-card .cover { position: absolute; inset: 0; background-size: cover; background-position: center; }
.book-card .genre-badge { position: absolute; top: 10px; left: 10px; font-size: 10px; font-weight: 600; backdrop-filter: blur(6px); border-radius: 7px; padding: 4px 9px; }
.book-card .star-over { position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%; border: none; backdrop-filter: blur(6px); cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.book-card .lock { position: absolute; inset: 0; background: rgba(17,24,39,.6); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; backdrop-filter: blur(1px); }
.book-card .lock i { font-size: 20px; margin-bottom: 8px; }
.book-card .lock span { font-size: 11.5px; font-weight: 600; }
.book-card .scrim { position: absolute; left: 0; right: 0; bottom: 0; padding: 34px 14px 14px; background: linear-gradient(to top, rgba(8,6,18,.95) 0%, rgba(8,6,18,.74) 44%, rgba(8,6,18,0) 100%); }
.book-card .bt { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.22; }
.book-card .ba { font-size: 12px; color: rgba(255,255,255,.72); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-card .bm { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; font-size: 11px; color: rgba(255,255,255,.62); }
.book-card .bm i { font-size: 10px; }
.book-card .bm .v { display: flex; align-items: center; gap: 5px; }
.show-more-wrap { text-align: center; margin-top: 36px; }
.show-more { padding: 12px 28px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; box-shadow: var(--shadow-card); transition: all .16s ease; }
.show-more:hover { border-color: var(--indigo); color: var(--indigo); }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.empty i { font-size: 26px; margin-bottom: 12px; display: block; }

/* ---------- PRICING ---------- */
.pricing { margin: 60px 0 80px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 24px; padding: 56px 40px; }
.pricing-head { text-align: center; margin-bottom: 44px; }
.pricing-head h2 { font-size: 32px; font-weight: 800; color: var(--ink); margin: 0 0 10px; letter-spacing: -.02em; }
.pricing-head p { font-size: 16px; color: var(--ink-soft); margin: 0; }
.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; align-items: stretch; max-width: 960px; margin: 0 auto; }
.plan { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px; display: flex; flex-direction: column; }
.plan.pro { border: 2px solid var(--indigo); box-shadow: 0 18px 40px -20px rgba(79,70,229,.4); }
.plan .pop { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--indigo); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .04em; border-radius: 16px; padding: 4px 14px; box-shadow: 0 4px 12px rgba(79,70,229,.35); }
.plan .pn { font-size: 15px; font-weight: 700; letter-spacing: .02em; color: var(--ink); }
.plan.pro .pn { color: var(--indigo); }
.plan .pt { font-size: 13px; color: var(--ink-soft); margin: 5px 0 20px; }
.plan .pp { display: flex; align-items: baseline; gap: 5px; margin-bottom: 22px; }
.plan .pp b { font-size: 40px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.plan .pp span { font-size: 14px; color: var(--ink-faint); }
.plan .feats { display: flex; flex-direction: column; gap: 12px; margin-bottom: 26px; flex: 1; }
.plan .feat { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; }
.plan .feat i { font-size: 13px; margin-top: 2px; }
.plan .feat.on { color: var(--ink-soft); } .plan .feat.on i { color: #22c55e; }
.plan .feat.off { color: var(--ink-faint); } .plan .feat.off i { color: var(--ink-faint); }
.plan .pcta { width: 100%; padding: 12px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; transition: all .16s ease; }
.plan.pro .pcta { border: none; background: var(--indigo); color: #fff; }
.plan.unlim .pcta { border: none; background: var(--ink); color: var(--bg); }

/* ---------- PAGE HEADERS (catalog/authors/news) ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 48px 24px 80px; }
.page-head { text-align: center; margin-bottom: 26px; }
.page-head h1 { font-size: 38px; font-weight: 800; color: var(--ink); margin: 0 0 10px; letter-spacing: -.02em; }
.page-head p { font-size: 16px; color: var(--ink-soft); margin: 0; }

/* ---------- CATALOG TOOLBAR + TABLE ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 16px; }
.tb-search { position: relative; display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 11px; padding: 0 16px; min-width: 320px; box-shadow: var(--shadow-card); }
.tb-search i { color: var(--ink-faint); font-size: 13px; margin-right: 10px; }
.tb-search input { flex: 1; border: none; background: transparent; color: var(--ink); font-size: 14px; padding: 11px 0; }
.tb-dd { display: flex; align-items: center; gap: 9px; padding: 11px 16px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface); color: var(--ink-soft); font-size: 13.5px; font-weight: 500; cursor: pointer; box-shadow: var(--shadow-card); }
.tb-dd > i:first-child { font-size: 12px; color: var(--indigo); }
.tb-dd .fa-chevron-down { font-size: 10px; }
.cat-stats { display: flex; align-items: center; justify-content: center; gap: 20px; font-size: 13px; color: var(--ink-faint); margin-bottom: 20px; }
.cat-stats b { color: var(--ink); }
.cat-stats .sep { color: var(--line-strong); }
.table { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-card); }
.table-head, .trow { display: grid; grid-template-columns: 1fr 160px 70px 120px 118px; gap: 16px; align-items: center; }
.table-head { padding: 12px 22px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.trow { padding: 11px 22px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .14s ease; }
.trow:hover { background: var(--surface-2); }
.trow:last-child { border-bottom: none; }
.tb-book { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mini-cover { position: relative; width: 40px; height: 57px; border-radius: 6px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 14px -8px rgba(0,0,0,.5); background-size: cover; background-position: center; }
.mini-cover > i { font-size: 13px; color: rgba(255,255,255,.4); }
.mini-cover .mlock { position: absolute; inset: 0; background: rgba(17,24,39,.5); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #fff; }
.tb-title { font-size: 14.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-author { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.genre-chip-sm { display: inline-block; font-size: 12px; color: var(--indigo); background: var(--indigo-soft); border-radius: 7px; padding: 4px 10px; white-space: nowrap; }
.tb-year { font-size: 13px; color: var(--ink-soft); }
.tb-views { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-faint); }
.tb-views i { font-size: 11px; }
.tb-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.fav-sq { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-faint); cursor: pointer; font-size: 12px; flex-shrink: 0; }
.fav-sq.on { border-color: var(--indigo); background: var(--indigo-soft); color: var(--star); }
.btn-summary { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 9px; border: none; background: var(--indigo); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.pager { display: flex; justify-content: center; gap: 8px; margin-top: 40px; flex-wrap: wrap; }
.page-btn { min-width: 42px; height: 42px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); font-weight: 600; font-size: 14px; cursor: pointer; }
.page-btn.active { border-color: var(--indigo); background: var(--indigo); color: #fff; }

/* ---------- AUTHORS ---------- */
.authors-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 34px; }
.author-card { display: flex; align-items: center; gap: 13px; padding: 15px 16px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; text-align: left; box-shadow: var(--shadow-card); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.author-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--indigo) 45%, var(--line)); }
.author-card.active { border-color: var(--indigo); background: var(--indigo-soft); }
.author-card .av { width: 46px; height: 46px; border-radius: 50%; background: var(--surface-2); color: var(--ink-soft); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.author-card.active .av { background: var(--indigo); color: #fff; }
.author-card .an { display: block; font-size: 14.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.author-card .as { display: block; font-size: 11.5px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.author-books-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.author-books-head h2 { font-size: 18px; font-weight: 700; color: var(--ink); margin: 0; display: flex; align-items: center; gap: 10px; }
.author-books-head h2 i { color: var(--indigo); font-size: 15px; }
.author-books-head .cnt { font-size: 12.5px; color: var(--ink-faint); }

/* ---------- NEWS ---------- */
.news-list { display: flex; flex-direction: column; gap: 18px; }
.news-card { display: grid; grid-template-columns: 150px 1fr; gap: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; align-items: center; box-shadow: var(--shadow-card); transition: border-color .2s ease; }
.news-card:hover { border-color: color-mix(in srgb, var(--indigo) 35%, var(--line)); }
.news-cover { aspect-ratio: 4/3; border-radius: 11px; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.9); font-size: 30px; background-size: cover; background-position: center; }
.news-meta { display: flex; align-items: center; gap: 11px; margin-bottom: 9px; }
.news-tag { font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--indigo); background: var(--indigo-soft); border-radius: 6px; padding: 3px 9px; }
.news-date { font-size: 12px; color: var(--ink-faint); }
.news-card h2 { font-size: 20px; font-weight: 700; color: var(--ink); margin: 0 0 7px; line-height: 1.25; }
.news-card p { font-size: 14px; color: var(--ink-soft); margin: 0 0 12px; line-height: 1.55; }
.news-foot { display: flex; align-items: center; gap: 18px; font-size: 12.5px; color: var(--ink-faint); }
.news-foot span { display: flex; align-items: center; gap: 6px; }
.news-like { display: flex; align-items: center; gap: 6px; border: none; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: 12.5px; }
.news-like.on { color: #ef4444; }

/* ---------- FOOTER ---------- */
.footer { background: var(--surface); border-top: 1px solid var(--line); margin-top: 20px; }
.footer-grid { max-width: 1180px; margin: 0 auto; padding: 44px 24px; display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.3fr; gap: 36px; }
.footer-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.footer-brand i { color: var(--indigo); font-size: 20px; }
.footer-brand span { font-size: 19px; font-weight: 800; color: var(--ink); }
.footer p { font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; max-width: 260px; margin: 0; }
.footer .fh { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 13px; }
.footer .fcol { display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; color: var(--ink-soft); }
.footer .fcol span { cursor: pointer; }
.footer-bottom { border-top: 1px solid var(--line); padding: 18px 24px; max-width: 1180px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--ink-faint); }

/* ---------- MODALS (shared) ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; }
.overlay .backdrop { position: absolute; inset: 0; background: rgba(17,24,39,.55); backdrop-filter: blur(5px); }
.modal { position: relative; width: 100%; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: 0 40px 90px -36px rgba(0,0,0,.6); max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
.bm-scroll, .pf-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.x-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); cursor: pointer; }

/* Book modal */
.book-modal { max-width: 800px; }
.bm-head { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 15px 24px; background: var(--bg); border-bottom: 1px solid var(--line); }
.bm-head .t { font-size: 16px; font-weight: 600; color: var(--ink); }
.bm-body { padding: 28px 32px 32px; }
.bm-top { display: flex; gap: 26px; margin-bottom: 26px; }
.bm-cover { flex-shrink: 0; width: 130px; height: 196px; border-radius: 10px; display: flex; align-items: center; justify-content: center; box-shadow: 0 18px 36px -18px rgba(0,0,0,.5); background-size: cover; background-position: center; }
.bm-cover > i { font-size: 30px; color: rgba(255,255,255,.4); }
.bm-info { flex: 1; min-width: 0; }
.bm-info h2 { font-size: 27px; font-weight: 800; color: var(--ink); margin: 0 0 6px; line-height: 1.15; letter-spacing: -.01em; }
.bm-info .au { font-size: 15px; color: var(--ink-soft); margin-bottom: 14px; }
.bm-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.bm-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); background: var(--surface-2); border-radius: 8px; padding: 6px 11px; }
.bm-chip i { font-size: 11px; color: var(--indigo); }
.bm-actions { display: flex; gap: 10px; }
.btn-listen { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 11px; border: none; background: var(--indigo); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; }
.btn-listen:disabled { opacity: .6; cursor: default; }
.fav-lg { width: 44px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-faint); font-size: 15px; cursor: pointer; }
.fav-lg.on { border-color: var(--indigo); background: var(--indigo-soft); color: var(--star); }
.tts-bar { margin-top: 14px; display: flex; align-items: center; gap: 11px; }
.tts-bar .track { flex: 1; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.tts-bar .fill { width: 0%; height: 100%; background: var(--indigo); transition: width .2s ease; }
.tts-bar .time { font-size: 11.5px; color: var(--ink-faint); }
.summary { border-top: 1px solid var(--line); padding-top: 24px; }
.summary h3 { font-size: 18px; font-weight: 700; color: var(--ink); margin: 22px 0 10px; }
.summary p { font-size: 15.5px; line-height: 1.7; color: var(--ink-soft); margin: 0 0 15px; max-width: 64ch; }
.summary strong { color: var(--ink); font-weight: 700; }
.summary em { font-style: italic; }
.summary ul, .summary ol { margin: 0 0 15px; padding-left: 22px; max-width: 64ch; }
.summary li { font-size: 15.5px; line-height: 1.7; color: var(--ink-soft); margin-bottom: 6px; }
.summary li strong { color: var(--ink); }
.bm-foot { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding: 14px 24px; font-size: 13px; color: var(--ink-soft); }
.bm-foot .v { display: flex; align-items: center; gap: 7px; } .bm-foot .v i { color: var(--indigo); }
.btn-soft { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 9px; border: none; background: var(--surface-2); color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer; }

/* Profile modal */
.profile-modal { max-width: 600px; border-radius: 20px; }
.pf-banner { position: relative; height: 120px; background: radial-gradient(120% 160% at 50% -40%, var(--indigo) 0%, var(--indigo-strong) 60%, color-mix(in srgb, var(--indigo-strong) 70%, #000) 100%); overflow: hidden; }
.pf-banner .glow { position: absolute; inset: 0; background-image: radial-gradient(circle at 18% 30%, rgba(255,255,255,.14) 0, transparent 42%), radial-gradient(circle at 82% 70%, rgba(255,255,255,.10) 0, transparent 40%); }
.pf-banner .x { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 10px; border: none; background: rgba(0,0,0,.22); color: #fff; cursor: pointer; font-size: 14px; backdrop-filter: blur(4px); }
.pf-id { text-align: center; padding: 0 32px; }
.pf-ava { position: relative; z-index: 2; width: 96px; height: 96px; border-radius: 50%; margin: -52px auto 0; background: linear-gradient(135deg, var(--indigo), var(--indigo-strong)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 38px; border: 5px solid var(--bg); box-shadow: 0 12px 28px -12px rgba(79,70,229,.6); overflow: hidden; }
.pf-ava img { width: 100%; height: 100%; object-fit: cover; }
.pf-name { font-size: 23px; font-weight: 800; color: var(--ink); margin-top: 14px; letter-spacing: -.01em; }
.pf-email { font-size: 13.5px; color: var(--ink-soft); margin-top: 3px; }
.pf-plan { display: inline-flex; align-items: center; gap: 6px; margin-top: 11px; font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--indigo); background: var(--indigo-soft); border-radius: 20px; padding: 6px 13px; text-transform: uppercase; }
.pf-plan i { font-size: 10px; }
.pf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 22px 32px 4px; }
.pf-stat { text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 8px; }
.pf-stat > i { color: var(--indigo); font-size: 16px; }
.pf-stat .val { font-size: 22px; font-weight: 800; color: var(--ink); margin-top: 8px; }
.pf-stat .lbl { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.pf-tabs { padding: 20px 32px 0; }
.seg { display: flex; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.seg-btn { flex: 1; padding: 9px 10px; border: none; border-radius: 9px; background: transparent; color: var(--ink-soft); font-weight: 500; font-size: 13.5px; cursor: pointer; transition: all .16s ease; }
.seg-btn.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(17,24,39,.14); }
.pf-content { padding: 22px 32px 32px; }
.pf-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pf-field { display: flex; align-items: center; gap: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 14px 16px; }
.pf-field .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--indigo-soft); color: var(--indigo); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.pf-field .l { font-size: 11px; color: var(--ink-faint); margin-bottom: 2px; }
.pf-field .v { font-size: 14.5px; color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-edit { width: 100%; margin-top: 14px; padding: 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.pf-edit i { font-size: 12px; color: var(--indigo); }
.sub-card { border: 1.5px solid var(--indigo); border-radius: 16px; padding: 22px; background: linear-gradient(160deg, var(--indigo-soft), transparent); }
.sub-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.sub-top .l { font-size: 11px; font-weight: 600; letter-spacing: .05em; color: var(--ink-faint); }
.sub-top .plan-row { display: flex; align-items: center; gap: 9px; margin-top: 5px; }
.sub-top .pn { font-size: 26px; font-weight: 800; color: var(--ink); }
.sub-top .pp { font-size: 13px; color: var(--ink-faint); }
.sub-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: #16a34a; background: rgba(34,197,94,.14); border-radius: 8px; padding: 6px 12px; }
.sub-badge i { font-size: 7px; }
.sub-meter .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.sub-meter .row b { font-weight: 600; color: var(--ink); }
.sub-meter .track { height: 9px; border-radius: 9px; background: var(--surface-2); overflow: hidden; }
.sub-meter .fill { height: 100%; border-radius: 9px; background: linear-gradient(90deg, var(--indigo), var(--indigo-strong)); }
.sub-renew { font-size: 12px; color: var(--ink-faint); margin-top: 14px; }
.sub-actions { display: flex; gap: 10px; margin-top: 14px; }
.sub-actions .up { flex: 1; padding: 12px; border-radius: 12px; border: none; background: var(--indigo); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; }
.sub-actions .cancel { padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); font-weight: 500; font-size: 14px; cursor: pointer; }
.hist-list { display: flex; flex-direction: column; gap: 9px; }
.hist-item { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 11px 14px; cursor: pointer; transition: border-color .16s ease; }
.hist-item:hover { border-color: color-mix(in srgb, var(--indigo) 40%, var(--line)); }
.hist-item .mc { width: 40px; height: 57px; border-radius: 7px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 14px -8px rgba(0,0,0,.5); background-size: cover; background-position: center; }
.hist-item .mc i { font-size: 13px; color: rgba(255,255,255,.4); }
.hist-item .ht { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item .ha { font-size: 12px; color: var(--ink-soft); }
.hist-item .hd { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-faint); flex-shrink: 0; margin-left: auto; }

/* Chat modal */
.chat-modal { max-width: 880px; height: 72vh; display: grid; grid-template-columns: 260px 1fr; overflow: hidden; }
.chat-side { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.chat-side .title { padding: 17px 18px 12px; font-size: 18px; font-weight: 700; color: var(--ink); }
.chat-friends { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.friend { width: 100%; display: flex; align-items: center; gap: 11px; padding: 10px 11px; border: none; border-radius: 12px; background: transparent; cursor: pointer; text-align: left; margin-bottom: 2px; }
.friend.active { background: var(--indigo-soft); }
.friend .av { position: relative; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--ink-soft); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0; overflow: hidden; }
.friend .av.bot { background: var(--indigo); color: #fff; }
.friend .av img { width: 100%; height: 100%; object-fit: cover; }
.friend .dot { position: absolute; bottom: 0; right: 0; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); background: var(--ink-faint); }
.friend .dot.online { background: #22c55e; }
.friend .fn { display: block; font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend .fp { display: block; font-size: 12px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.chat-head .av { width: 38px; height: 38px; border-radius: 50%; background: var(--indigo); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; overflow: hidden; }
.chat-head .av img { width: 100%; height: 100%; object-fit: cover; }
.chat-head .nm { font-size: 15px; font-weight: 600; color: var(--ink); }
.chat-head .st { font-size: 12px; color: #22c55e; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 11px; }
.bubble { max-width: 72%; padding: 10px 14px; font-size: 14px; line-height: 1.5; word-wrap: break-word; }
.bubble.them { align-self: flex-start; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 14px 14px 14px 4px; }
.bubble.me { align-self: flex-end; background: var(--indigo); color: #fff; border-radius: 14px 14px 4px 14px; }
.bubble .tm { font-size: 10px; margin-top: 5px; text-align: right; }
.bubble.them .tm { color: var(--ink-faint); } .bubble.me .tm { color: rgba(255,255,255,.7); }
.chat-input { padding: 15px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.chat-input input { flex: 1; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 11px; padding: 11px 15px; font-size: 14px; }
.chat-send { width: 46px; border-radius: 11px; border: none; background: var(--indigo); color: #fff; font-size: 15px; cursor: pointer; }

/* Auth modal */
.auth-modal { max-width: 460px; border-radius: 20px; padding: 0; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--line); position: relative; }
.auth-tab { flex: 1; padding: 20px; border: none; background: transparent; color: var(--ink-faint); font-size: 16px; font-weight: 600; cursor: pointer; }
.auth-tab.active { color: var(--indigo); }
.auth-tab.active::after { content: ''; position: absolute; bottom: -1px; height: 2px; background: var(--indigo); border-radius: 2px; }
.auth-close { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; border-radius: 9px; border: none; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: 16px; z-index: 3; }
.auth-body { padding: 26px 28px 30px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
.field label .req { color: #ef4444; }
.field input { width: 100%; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 12px 14px; font-size: 15px; }
.field input:focus { border-color: var(--indigo); }
.field .err { font-size: 12.5px; color: #ef4444; margin-top: 6px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; font-size: 13.5px; }
.auth-row a { color: var(--indigo); cursor: pointer; }
.remember { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); cursor: pointer; }
.btn-primary { width: 100%; padding: 13px; border-radius: 11px; border: none; background: var(--indigo); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; }
.btn-primary:hover { background: var(--indigo-strong); }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* Toast */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 11px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-hover); animation: bkxIn .25s ease; max-width: 90vw; }
.toast.err { background: #ef4444; color: #fff; }
.toast.ok { background: #16a34a; color: #fff; }

/* Responsive */
@media (max-width: 1080px) { .book-grid { grid-template-columns: repeat(4, 1fr); } .authors-grid { grid-template-columns: repeat(3, 1fr); } .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) {
  .hero h1 { font-size: 36px; } .nav-links { display: none; }
  .book-grid { grid-template-columns: repeat(3, 1fr); } .authors-grid { grid-template-columns: repeat(2, 1fr); }
  .pricing-grid { grid-template-columns: 1fr; } .table-head, .trow { grid-template-columns: 1fr 90px; }
  .table-head span:nth-child(2), .table-head span:nth-child(3), .table-head span:nth-child(4),
  .trow > div:nth-child(2), .trow > div:nth-child(3), .trow > div:nth-child(4) { display: none; }
  .chat-modal { grid-template-columns: 1fr; } .chat-side { display: none; }
  .news-card { grid-template-columns: 1fr; } .news-cover { max-height: 160px; }
  .pf-fields { grid-template-columns: 1fr; }
}
@media (max-width: 560px) { .book-grid { grid-template-columns: repeat(2, 1fr); } .container { padding: 0 16px; } .bm-top { flex-direction: column; } }
