/* BOOKVERSE — global styles, design tokens and shared components */
:root {
  --bg: #0b1020;
  --bg-soft: #101733;
  --bg-elevated: #141c3a;
  --surface: #151d3b;
  --surface-2: #1b2446;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.3);
  --text: #eef2ff;
  --text-soft: #b6c0da;
  --text-muted: #8490ad;
  --primary: #6366f1;
  --primary-hover: #7c7ff5;
  --primary-soft: rgba(99, 102, 241, 0.16);
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.14);
  --danger: #f87171;
  --success: #34d399;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 45px rgba(2, 6, 23, 0.42);
  --header-h: 74px;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f5f7fd;
  --bg-soft: #eef1fa;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f4fc;
  --border: rgba(30, 41, 59, 0.12);
  --border-strong: rgba(30, 41, 59, 0.22);
  --text: #141a33;
  --text-soft: #46516e;
  --text-muted: #6b7590;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --accent: #d97706;
  --accent-soft: rgba(245, 158, 11, 0.16);
  --danger: #dc2626;
  --success: #059669;
  --shadow: 0 16px 40px rgba(30, 41, 59, 0.1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1100px 600px at 85% -10%, rgba(99, 102, 241, 0.14), transparent 60%),
              radial-gradient(900px 500px at -10% 20%, rgba(245, 158, 11, 0.06), transparent 55%), var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}
main { flex: 1; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; }
p { margin: 0 0 1em; }
.container { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.hidden, [hidden] { display: none !important; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { min-height: var(--header-h); display: flex; align-items: center; gap: 22px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -.5px; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; }
.brand-accent { color: var(--accent); }
.nav-search { flex: 1; max-width: 430px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 5px 5px 14px; }
.nav-search svg, .search-icon svg { width: 18px; height: 18px; fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.nav-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13.5px; }
.nav-search input::placeholder { color: var(--text-muted); }
.nav-links { display: flex; align-items: center; gap: 18px; margin-left: auto; font-size: 13.5px; font-weight: 500; }
.nav-links a { color: var(--text-soft); white-space: nowrap; }
.nav-links a:hover, .nav-links a.active { color: var(--accent); }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-user { display: flex; align-items: center; gap: 8px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.user-chip-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); transition: .2s; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle svg circle, .theme-toggle svg path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: #1b1200; font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.mobile-menu-btn { display: none; }
.notification-wrap { position: relative; }
.notifications-panel { position: absolute; top: calc(100% + 12px); right: 0; width: 340px; max-height: 420px; overflow: auto; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 60; }
.notifications-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notifications-head button { background: none; border: 0; color: var(--primary); font-size: 11.5px; }
.notifications-list { display: flex; flex-direction: column; }
.notification-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notification-item:hover { background: var(--surface); }
.notification-item strong { display: block; font-size: 13px; }
.notification-item small { display: block; color: var(--text-soft); font-size: 12px; }
.notification-item em { display: block; font-style: normal; font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }
.notification-item.unread { background: var(--primary-soft); }
.notification-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--accent); margin-top: 7px; }
.notifications-empty { padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; padding: 11px 19px; font-weight: 600; font-size: 14px; transition: transform .18s, background .18s, border-color .18s, box-shadow .18s; white-space: nowrap; }
.btn:hover { transform: translateY(-2px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), #818cf8); color: white; box-shadow: 0 8px 20px rgba(99, 102, 241, .25); }
.btn-primary:hover { color: white; box-shadow: 0 12px 26px rgba(99, 102, 241, .35); }
.btn-accent { background: var(--accent); color: #1c1302; }
.btn-accent:hover { color: #1c1302; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-soft); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-danger { background: rgba(248, 113, 113, .12); color: var(--danger); border-color: rgba(248, 113, 113, .3); }
.btn-sm { padding: 7px 13px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 0; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.field label .req { color: var(--accent); }
.input, .field input, .field select, .field textarea {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; min-height: 100px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field input[type="file"] { padding: 9px; font-size: 12.5px; }
.field-hint { font-size: 11.5px; color: var(--text-muted); }
.form-error { background: rgba(248, 113, 113, .12); color: var(--danger); border: 1px solid rgba(248, 113, 113, .28); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.form-error:empty { display: none; }
.form-success { background: rgba(52, 211, 153, .12); color: var(--success); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }

/* Common UI */
.section { padding: 46px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-head h2 { font-size: clamp(25px, 3vw, 34px); margin-bottom: 4px; }
.section-head p { color: var(--text-muted); margin: 0; font-size: 14px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; margin-bottom: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 9px; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); border-radius: 999px; padding: 8px 15px; font-size: 13px; font-weight: 500; transition: .2s; }
.chip:hover, .chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip .chip-icon { font-size: 15px; }
.badge-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 700; }
.badge-pill.accent { background: var(--accent-soft); color: var(--accent); }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-sm { width: 30px; height: 30px; }
.avatar-lg { width: 90px; height: 90px; }
.avatar-fallback { display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; font-weight: 800; }
.empty-state { text-align: center; padding: 54px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-muted); background: var(--surface); }
.empty-state .empty-icon { font-size: 38px; margin-bottom: 10px; }
.empty-state h3 { color: var(--text); font-size: 20px; }
.empty-state p { max-width: 420px; margin: 0 auto 16px; font-size: 13.5px; }
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 30px; flex-wrap: wrap; }
.page-btn { min-width: 38px; height: 38px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); font-size: 13px; }
.page-btn:hover:not(:disabled), .page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.page-btn:disabled { opacity: .4; cursor: default; }
.page-info { color: var(--text-muted); font-size: 13px; padding: 0 6px; }

/* Book cards */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 22px; }
.book-card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: transform .22s, border-color .22s, box-shadow .22s; }
.book-card:hover { transform: translateY(-5px); border-color: rgba(99, 102, 241, .45); box-shadow: var(--shadow); }
.book-cover { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: linear-gradient(150deg, #312e81, #6366f1 55%, #b45309); display: grid; place-items: center; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.book-card:hover .book-cover img { transform: scale(1.04); }
.book-cover-fallback { padding: 18px; text-align: center; color: white; font-family: var(--font-display); font-size: 21px; line-height: 1.25; text-shadow: 0 2px 10px rgba(0,0,0,.3); }
.book-cover-fallback small { display: block; font-family: var(--font-sans); font-size: 11px; opacity: .8; margin-top: 8px; }
.fav-btn { position: absolute; top: 9px; right: 9px; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(11, 16, 32, .62); color: white; font-size: 17px; line-height: 1; backdrop-filter: blur(5px); transition: .2s; }
.fav-btn:hover { transform: scale(1.12); color: var(--accent); }
.fav-btn.is-active { color: var(--accent); }
.book-card-body { padding: 15px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.book-card-title { font-size: 15px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card-author { color: var(--text-muted); font-size: 12.5px; }
.book-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); }
.rating { color: var(--accent); font-weight: 700; }
.book-tags { display: flex; gap: 5px; flex-wrap: wrap; }

/* Hero */
.hero { padding: 62px 0 30px; }
.hero-inner { display: grid; grid-template-columns: 1.2fr .8fr; align-items: center; gap: 44px; }
.hero h1 { font-size: clamp(38px, 5.4vw, 62px); line-height: 1.08; letter-spacing: -1.5px; margin-bottom: 18px; }
.hero h1 em { color: var(--accent); font-style: italic; }
.hero-subtitle { font-size: 16px; color: var(--text-soft); max-width: 560px; margin-bottom: 26px; }
.hero-search { display: flex; gap: 10px; max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 7px; box-shadow: var(--shadow); }
.hero-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); padding: 8px 12px; outline: 0; }
.hero-stats { display: flex; gap: 26px; margin-top: 28px; }
.hero-stats strong { display: block; font-family: var(--font-display); font-size: 24px; color: var(--accent); }
.hero-stats span { color: var(--text-muted); font-size: 12px; }
.hero-art { position: relative; height: 330px; display: grid; place-items: center; }
.hero-art::before { content: ''; position: absolute; inset: 12% 10%; background: radial-gradient(circle, rgba(99,102,241,.35), transparent 65%); filter: blur(20px); }
.hero-art .art-book { position: absolute; width: 132px; height: 185px; border-radius: 8px 14px 14px 8px; box-shadow: 0 20px 40px rgba(0,0,0,.4); transform-origin: center; }
.hero-art .art-book::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 6px; background: rgba(0,0,0,.2); }
.art-1 { background: linear-gradient(145deg, #4f46e5, #312e81); transform: rotate(-12deg) translate(-60px, 8px); }
.art-2 { background: linear-gradient(145deg, #f59e0b, #b45309); z-index: 2; transform: rotate(3deg); }
.art-3 { background: linear-gradient(145deg, #0ea5e9, #1e3a8a); transform: rotate(14deg) translate(60px, 8px); }
.hero-art .art-glow { position: absolute; width: 200px; height: 200px; border: 1px solid var(--border-strong); border-radius: 50%; }

/* Auth pages */
.auth-wrap { display: grid; place-items: center; padding: 58px 20px 70px; }
.auth-card { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 34px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 30px; margin-bottom: 4px; }
.auth-card .auth-sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 24px; }
.auth-alt { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.auth-alt a { color: var(--primary); font-weight: 700; }
.auth-benefits { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

/* Detail page */
.detail-grid { display: grid; grid-template-columns: 300px 1fr; gap: 38px; align-items: start; }
.detail-cover { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow); }
.detail-cover-fallback { display: grid; place-items: center; text-align: center; padding: 30px; font-family: var(--font-display); font-size: 28px; }
.detail-title { font-size: clamp(28px, 4vw, 42px); margin-bottom: 8px; }
.detail-author { color: var(--primary); font-weight: 600; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 10px 20px; color: var(--text-muted); font-size: 13px; margin: 18px 0; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0; }
.description { color: var(--text-soft); line-height: 1.8; white-space: pre-line; }
.review { padding: 16px 0; border-top: 1px solid var(--border); }
.review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.review-head strong { font-size: 13.5px; }
.review-head small { color: var(--text-muted); font-size: 11px; }
.star-rating { color: var(--accent); letter-spacing: 2px; }
.file-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.file-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 12px; text-transform: uppercase; }
.file-row .file-info { flex: 1; min-width: 0; }
.file-row .file-info strong { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .file-info small { color: var(--text-muted); font-size: 11.5px; }
.file-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.stars-input { display: flex; gap: 4px; }
.star-btn { border: 0; background: none; color: var(--text-muted); font-size: 25px; padding: 0 2px; line-height: 1; }
.star-btn.active { color: var(--accent); }

/* Toast */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--bg-elevated); border: 1px solid var(--border); border-left: 3px solid var(--success); box-shadow: var(--shadow); padding: 12px 16px; border-radius: 11px; font-size: 13px; opacity: 0; transform: translateY(12px); transition: .25s; max-width: 340px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast-error { border-left-color: var(--danger); }
.toast-icon { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--success); color: #04140d; font-weight: 800; font-size: 12px; }
.toast-error .toast-icon { background: var(--danger); color: #240505; }

/* Footer */
.site-footer { margin-top: auto; background: var(--bg-soft); border-top: 1px solid var(--border); padding: 44px 0 20px; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1.4fr; gap: 36px; }
.footer-tagline, .footer-col p { color: var(--text-muted); font-size: 13px; margin-top: 12px; }
.footer-col { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.footer-col h4 { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.footer-col a { color: var(--text-muted); }
.footer-col a:hover { color: var(--accent); }
.footer-bottom { display: flex; justify-content: space-between; gap: 14px; border-top: 1px solid var(--border); margin-top: 34px; padding-top: 18px; color: var(--text-muted); font-size: 12px; }

/* Responsive */
@media (max-width: 1080px) {
  .nav-links { gap: 12px; }
  .nav-search { max-width: 300px; }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .nav-inner { flex-wrap: wrap; gap: 10px; padding: 10px 0; }
  .nav-search { order: 3; max-width: none; flex-basis: 100%; }
  .nav-links { display: none; width: 100%; flex-direction: column; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; }
  .nav-links.is-open { display: flex; }
  .mobile-menu-btn { display: inline-grid; margin-left: auto; }
  .nav-actions { margin-left: auto; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-art { height: 230px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-cover { max-width: 270px; }
}
@media (max-width: 600px) {
  .container { width: min(100% - 28px, 1180px); }
  .user-chip-name, .nav-actions > .btn-ghost { display: none; }
  .footer-grid { grid-template-columns: 1fr; gap: 22px; }
  .footer-bottom { flex-direction: column; }
  .hero { padding-top: 40px; }
  .hero-stats { gap: 18px; }
  .section { padding: 34px 0; }
  .section-head { align-items: start; flex-direction: column; }
  .notifications-panel { width: min(340px, calc(100vw - 30px)); right: -50px; }
  .toast-stack { left: 14px; right: 14px; bottom: 14px; }
  .toast { max-width: none; }
}
