/* Library System - Main styles */
:root {
  --bg: #f5f1eb;
  --card: #fff;
  --text: #2c2825;
  --muted: #6b6560;
  --accent: #8b6914;
  --accent-hover: #6d5210;
  --border: #e0d9d0;
  --error: #c0392b;
  --success: #27ae60;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
}
.header-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.logo { font-weight: 700; font-size: 1.25rem; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; gap: 0.5rem; }
.logo:hover { text-decoration: underline; }
.logo .site-logo { max-height: 40px; max-width: 160px; object-fit: contain; vertical-align: middle; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 1rem; }
.site-header nav a { color: var(--text); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); }
.site-header nav a.active { font-weight: 600; color: var(--accent); }
/* Hamburger hidden on desktop */
.nav-toggle-label { display: none; }

.main-content { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; min-height: 60vh; }
.page-lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 1.25rem; max-width: 640px; }

.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 1rem;
  background: var(--card);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-brand { font-weight: 700; font-size: 1.1rem; color: var(--accent); margin: 0 0 0.25rem; }
.footer-tagline { margin: 0 0 0.75rem; max-width: 480px; margin-left: auto; margin-right: auto; line-height: 1.5; }
.footer-copy { margin: 0.75rem 0 0; font-size: 0.8rem; color: var(--muted); opacity: 0.9; }

/* Auth */
.auth-page-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}
.auth-page-wrap .auth-card { margin: 0; margin-top: 0; }
.auth-page-header { text-align: center; margin-bottom: 1.25rem; }
.auth-page-hero { margin-bottom: 1rem; }
.auth-hero-img { display: block; margin: 0 auto; max-width: 140px; max-height: 80px; object-fit: contain; }
.auth-hero-svg { width: 120px; height: 64px; color: var(--accent); }
.auth-site-brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  text-decoration: none; color: var(--accent); font-weight: 700; font-size: 1.35rem;
  transition: color .2s, text-decoration .2s;
}
.auth-site-brand:hover { color: var(--accent-hover); text-decoration: underline; }
.auth-site-logo { max-height: 36px; max-width: 120px; object-fit: contain; vertical-align: middle; }
.auth-site-icon { font-size: 1.5rem; }
.auth-card { max-width: 400px; margin: 2rem auto; padding: 2rem; background: var(--card); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.auth-card h1 { margin-top: 0; }
.auth-card label { display: block; margin: 1rem 0; }
.auth-card input[type="text"], .auth-card input[type="email"], .auth-card input[type="password"] { width: 100%; padding: 0.5rem; }
.auth-card .checkbox { display: flex; align-items: center; gap: 0.5rem; }
.auth-card .checkbox input { width: auto; }
.auth-card button { padding: 0.5rem 1.5rem; background: var(--accent); color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.auth-card button:hover { background: var(--accent-hover); }
.auth-link {
  margin-top: 1.25rem; padding-top: 0.75rem; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem;
}
.auth-link a {
  display: inline-block; padding: 0.45rem 0.85rem;
  color: var(--accent); font-weight: 500; text-decoration: none;
  border: 1px solid var(--accent); border-radius: 6px;
  transition: background .2s, color .2s, border-color .2s, text-decoration .2s;
}
.auth-link a:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
  text-decoration: underline;
}
.auth-link-sep { color: var(--muted); font-size: 0.9rem; padding: 0 0.15rem; }
.auth-card .success a { color: var(--accent); text-decoration: none; }
.auth-card .success a:hover { text-decoration: underline; }
.error { color: var(--error); }
.success { color: var(--success); }

/* Buttons */
.btn { display: inline-block; padding: 0.5rem 1rem; background: var(--accent); color: #fff; text-decoration: none; border-radius: 4px; border: none; cursor: pointer; font-size: 1rem; }
.btn:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--muted); }
.btn-secondary:hover { background: #5a534e; }

/* Book grid */
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1.25rem; }
.book-card {
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  border: 1px solid var(--border);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.book-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 28px rgba(0,0,0,.12);
  border-color: var(--accent);
}
.book-card a { text-decoration: none; color: inherit; display: flex; flex-direction: column; height: 100%; }
.book-card .book-cover {
  transform: scale(1);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.book-card:hover .book-cover {
  transform: scale(1.03);
}
.book-cover { aspect-ratio: 2/3; background: var(--border); object-fit: cover; width: 100%; display: block; }
.book-cover.placeholder { display: block; min-height: 220px; background: linear-gradient(135deg, var(--border) 0%, #e8e4de 100%); }
.book-card .info { padding: 0.85rem; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.book-card .title {
  font-weight: 600;
  margin: 0 0 0.35rem;
  line-height: 1.35;
  font-size: 1rem;
  position: relative;
  display: inline-block;
  transition: color 0.22s ease;
}
.book-card .title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.book-card a:hover .title { color: var(--accent); }
.book-card a:hover .title::after { transform: scaleX(1); transform-origin: left; }
.book-card .meta { font-size: 0.8rem; color: var(--muted); margin: 0; line-height: 1.4; }
.book-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: auto; padding-top: 0.5rem; }
.book-card-actions { padding: 0.5rem 0.85rem 0.85rem; border-top: 1px solid var(--border); }
.book-card-actions .btn-sm { font-size: 0.85rem; }
.badge { font-size: 0.68rem; padding: 0.22rem 0.45rem; border-radius: 4px; background: var(--border); color: var(--muted); }
.badge.free { background: #d4edda; color: #155724; }
.badge.paid { background: #fff3cd; color: #856404; }
.badge.downloadable { background: #cce5ff; color: #004085; }
.badge.web { background: #e2e3e5; }
.badge.app { background: #e2e3e5; }
.badge.badge-access { background: #e8e0f0; color: #4a3d6b; }
.access-note { font-size: 0.9rem; color: var(--success); margin-right: 0.5rem; }
.paid-access-box {
  background: #f8f6f0; border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem; margin: 0.5rem 0;
}
.paid-access-msg { margin: 0 0 0.5rem; }
.paid-access-duration { margin: 0; color: var(--muted); }

/* Book detail */
.book-detail { display: grid; grid-template-columns: 240px 1fr; gap: 2.5rem; align-items: start; margin-top: 0.5rem; }
@media (max-width: 640px) { .book-detail { grid-template-columns: 1fr; gap: 1.5rem; } }
.book-detail .cover-col { position: sticky; top: 1rem; }
.book-detail .cover { width: 100%; max-width: 240px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.1); display: block; }
.book-detail .cover.placeholder,
.book-detail .cover-col .book-cover.placeholder { aspect-ratio: 2/3; min-height: 320px; background: linear-gradient(135deg, var(--border) 0%, #e8e4de 100%); border-radius: 10px; }
.book-detail .info-col h1 { margin: 0 0 0.75rem; font-size: 1.75rem; line-height: 1.3; }
.book-detail .meta-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.book-detail .meta-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.book-detail .meta-list li strong { display: inline-block; width: 100px; color: var(--muted); font-weight: 500; }
.book-detail .meta-list a { color: var(--accent); text-decoration: none; }
.book-detail .meta-list a:hover { text-decoration: underline; }
.book-detail .description { margin: 1.25rem 0; padding: 1rem 0; border-top: 1px solid var(--border); }
.book-detail .description h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.book-detail .description p { margin: 0; line-height: 1.65; color: var(--text); }
.book-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.25rem 0; align-items: center; }
.book-actions .btn { margin-right: 0; }

/* Themes list */
.themes-list { display: flex; flex-wrap: wrap; gap: 1rem; }
.themes-list a { display: block; padding: 1rem 1.5rem; background: var(--card); border-radius: 8px; text-decoration: none; color: var(--text); box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.themes-list a:hover { background: var(--accent); color: #fff; }

/* Pagination */
.pagination { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.5rem 0; align-items: center; }
.pagination a, .pagination span { padding: 0.4rem 0.8rem; border-radius: 4px; }
.pagination a { background: var(--card); color: var(--accent); text-decoration: none; }
.pagination a:hover { background: var(--accent); color: #fff; }
.pagination .current { background: var(--accent); color: #fff; }
.pagination .disabled { color: var(--muted); }

/* Forms */
.container { max-width: 700px; }
.admin-add-user { margin-bottom: 2rem; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.admin-add-user h2 { margin-top: 0; margin-bottom: 0.75rem; font-size: 1.2rem; }
.admin-add-user .btn { margin-top: 0.5rem; }
form label { display: block; margin: 0.75rem 0; }
form input[type="text"], form input[type="email"], form input[type="number"], form input[type="date"], form input[type="url"], form select, form textarea { width: 100%; padding: 0.5rem; }
form textarea { min-height: 100px; }
.profile-stats { margin: 1rem 0; }
.profile-form button { margin-top: 0.5rem; }

/* Admin dashboard */
.page-admin h1 { margin-bottom: 0.75rem; }
.page-admin .toolbar { margin: 0 0 1.5rem; padding: 0; border: none; background: transparent; gap: 0.75rem; flex-wrap: wrap; }
.page-admin .toolbar .btn { white-space: nowrap; }

.admin-stats { margin: 1.5rem 0; }
.admin-stats > div {
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
  border: 1px solid var(--border);
}

.admin-two-col { margin-top: 1.25rem; }
.page-admin .admin-two-col h3 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.page-admin .admin-two-col ul { list-style: none; padding-left: 0; margin: 0; }
.page-admin .admin-two-col li { padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
.page-admin .admin-two-col li:last-child { border-bottom: none; }
.page-admin .admin-two-col a { color: var(--accent); text-decoration: none; font-weight: 650; }
.page-admin .admin-two-col a:hover { text-decoration: underline; color: var(--accent-hover); }

.page-admin > h3 { margin: 2rem 0 0.75rem; font-size: 1.1rem; }
.page-admin .table-wrap { margin-top: 1rem; }

/* Reader – book reading view */
.main-content.reader-main { padding: 0; max-width: none; }
.reader-page { padding: 0; margin: 0; min-height: calc(100vh - 120px); display: flex; flex-direction: column; }
.reader-toolbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
  padding: 0.6rem 1rem; background: var(--card);
  border-bottom: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.reader-toolbar-left { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.reader-back {
  flex-shrink: 0;
  display: inline-flex; align-items: center;
  padding: 0.4rem 0.6rem; border-radius: 6px;
  background: var(--bg); color: var(--text); text-decoration: none; font-size: 0.95rem;
  transition: background .15s;
}
.reader-back:hover { background: var(--border); color: var(--accent); }
.reader-title {
  font-weight: 600; font-size: 1rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.reader-toolbar-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.reader-btn {
  display: inline-flex; align-items: center;
  padding: 0.4rem 0.75rem; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-size: 0.9rem; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.reader-btn:hover { background: var(--border); }
.reader-btn-fullscreen { font-family: inherit; }
.reader-btn-fullscreen:hover { border-color: var(--accent); color: var(--accent); }

.reader-frame-wrap { flex: 1; padding: 1rem; min-height: 0; }
.reader-frame {
  max-width: 900px; margin: 0 auto;
  background: #fff; border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.08), 0 0 1px rgba(0,0,0,.06);
  overflow: hidden; height: calc(100vh - 180px); min-height: 480px;
}
.reader-frame iframe {
  display: block; width: 100%; height: 100%; border: none;
}
.reader-other {
  padding: 2rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.reader-other p { margin: 0; color: var(--muted); }

/* Fullscreen reading mode */
body.reader-fullscreen-on .site-header,
body.reader-fullscreen-on .site-footer { display: none !important; }
body.reader-fullscreen-on .main-content { padding: 0; max-width: none; }
body.reader-fullscreen-on .reader-page { margin: 0; min-height: 100vh; }
body.reader-fullscreen-on .reader-toolbar { border-radius: 0; }
body.reader-fullscreen-on .reader-frame-wrap { padding: 0.5rem; }
body.reader-fullscreen-on .reader-frame {
  max-width: none; height: calc(100vh - 52px); min-height: 400px;
  border-radius: 4px;
}

.reader-format-badge { font-size: 0.75rem; color: var(--muted); margin-left: 0.5rem; padding: 0.2rem 0.5rem; background: var(--border); border-radius: 4px; }
.reader-text-wrap { padding: 1.5rem; overflow: auto; height: 100%; }
.reader-text-content {
  white-space: pre-wrap; word-wrap: break-word; font-family: inherit; font-size: 1rem;
  line-height: 1.6; margin: 0; max-width: 70ch; margin: 0 auto;
}
.reader-epub-viewer { width: 100%; height: 100%; min-height: 400px; background: #fff; }
.reader-epub-viewer iframe { border: none; width: 100%; height: 100%; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 8px; overflow: hidden; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--border); font-weight: 600; }

/* Page title */
h1 { margin-top: 0; margin-bottom: 0.5rem; }
.toolbar { display: flex; justify-content: flex-start; align-items: center; flex-wrap: wrap; gap: 0.75rem 1.25rem; margin: 1rem 0; padding: 0.75rem 0; }
.toolbar label { margin: 0; }
.toolbar input[type="search"] { min-width: 200px; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; }
.toolbar select { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card); min-width: 140px; }
.books-count { color: var(--muted); font-size: 0.95rem; margin: 0 0 1rem; }

/* Books listing page */
.page-books { max-width: 100%; }
.page-books-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.page-books-header h1 { margin: 0; flex: 0 0 auto; }
.page-books-header .toolbar { margin: 0; padding: 0; border: none; background: transparent; align-items: center; flex-wrap: nowrap; gap: 0.75rem 1rem; }
.page-books-header .toolbar label { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.page-books-header .toolbar input[type="search"],
.page-books-header .toolbar select,
.page-books-header .toolbar .btn {
  height: 2.25rem;
  min-height: 2.25rem;
  box-sizing: border-box;
  line-height: 1.25;
}
.page-books-header .toolbar-search { flex: 1 1 220px; min-width: 0; }
.page-books-header .toolbar-filters { flex: 1 1 auto; min-width: 0; }
.page-books .books-count { margin-top: 0; margin-bottom: 1rem; }
.page-books .books-grid { margin-top: 0; margin-bottom: 1.5rem; grid-template-columns: repeat(4, 1fr); }

/* Review item */
.review-item { margin: 1rem 0; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.review-item p { margin: 0.25rem 0 0; }

/* Table wrapper for horizontal scroll on mobile */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0; }
.table-wrap table { min-width: 500px; }

/* ========== Landing page ========== */
.landing-hero {
  position: relative;
  color: #fff; text-align: center; padding: 3rem 1.5rem;
  overflow: hidden;
}
.landing-hero-bg {
  position: absolute; inset: 0; z-index: 0;
}
.landing-hero-bg-slide {
  position: absolute; inset: 0;
  background-color: var(--accent);
  background-size: cover; background-position: center;
  animation: landing-hero-slide 12s ease-in-out infinite;
}
.landing-hero-bg-slide-1 {
  background-image: url('../images/hero/slide1.jpg');
  animation-delay: 0s;
}
.landing-hero-bg-slide-2 {
  background-image: url('../images/hero/slide2.jpg');
  animation-delay: -4s;
}
.landing-hero-bg-slide-3 {
  background-image: url('../images/hero/slide3.jpg');
  animation-delay: -8s;
}
@keyframes landing-hero-slide {
  0%, 28% { opacity: 1; transform: scale(1); }
  33%, 61% { opacity: 0; transform: scale(1.05); }
  66%, 94% { opacity: 0; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}
.landing-hero-bg-slide-2 { animation-name: landing-hero-slide-2; }
@keyframes landing-hero-slide-2 {
  0%, 28% { opacity: 0; transform: scale(1.05); }
  33%, 61% { opacity: 1; transform: scale(1); }
  66%, 94% { opacity: 0; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.05); }
}
.landing-hero-bg-slide-3 { animation-name: landing-hero-slide-3; }
@keyframes landing-hero-slide-3 {
  0%, 28% { opacity: 0; transform: scale(1.05); }
  33%, 61% { opacity: 0; transform: scale(1.05); }
  66%, 94% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.05); }
}
.landing-hero-overlay {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(135deg, rgba(139, 105, 20, 0.85) 0%, rgba(109, 82, 16, 0.9) 100%);
}
.landing-hero-inner { position: relative; z-index: 2; max-width: 700px; margin: 0 auto; }
.landing-hero-title { margin: 0 0 0.5rem; font-size: 2.25rem; font-weight: 700; }
.landing-hero-tagline { margin: 0 0 0.75rem; font-size: 1.2rem; opacity: 0.95; }
.landing-hero-desc { margin: 0 0 1.5rem; opacity: 0.9; line-height: 1.6; }
.landing-hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }
.btn-hero { background: #fff; color: var(--accent); }
.btn-hero:hover { background: #f5f1eb; color: var(--accent-hover); }
.btn-outline { background: transparent; border: 2px solid rgba(255,255,255,0.8); color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,0.2); border-color: #fff; color: #fff; }
.btn-outline-light { background: transparent; border: 2px solid var(--card); color: var(--text); }
.btn-outline-light:hover { background: var(--card); color: var(--accent); }

.landing-section { padding: 2.5rem 1rem; }
.landing-section-alt { background: linear-gradient(180deg, #f6f5f2 0%, #eeebe6 100%); }
.landing-section-inner { max-width: 1000px; margin: 0 auto; }
#about .landing-section-inner { max-width: 720px; }
#recent-books .landing-section-inner { padding: 0 0.5rem; }
#recent-books .books-grid { margin: 0 0 1.5rem; grid-template-columns: repeat(4, 1fr); }
.landing-section-title { margin: 0 0 1rem; font-size: 1.5rem; text-align: center; }
.landing-empty { margin: 0; text-align: center; color: var(--muted); }
.landing-cta-link { margin: 0; text-align: center; }
.landing-cta-link .btn { margin: 0; }
.landing-lead { margin: 0 auto 1.25rem; font-size: 1.05rem; line-height: 1.6; color: var(--muted); max-width: 640px; text-align: center; }
.landing-about-list { margin: 1rem auto 1.5rem; padding-left: 1.5rem; max-width: 560px; list-style: disc; }
.landing-about-list li { margin: 0.5rem 0; line-height: 1.5; }
.landing-about-cta { margin: 1rem 0 0; text-align: center; }
.landing-about-cta .btn { margin: 0; }

/* Features slider: one slide at a time, centered */
.landing-features-slider {
  position: relative;
  max-width: 720px;
  margin: 1.25rem auto 0;
  padding: 0 52px;
}
.landing-features-slider .landing-features {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 0;
  margin: 0;
  padding: 0.5rem 0 1rem;
}
.landing-features-slider .landing-features::-webkit-scrollbar { display: none; }
.landing-features-slider .landing-feature {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  box-sizing: border-box;
}
.landing-feature {
  text-align: center;
  padding: 1.75rem 1.5rem 1.5rem;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 14px rgba(0,0,0,.06);
  transition: box-shadow .2s ease, border-color .2s ease;
  min-height: 180px;
}
/* Different background per feature card (slider slide) */
.landing-features-slider .landing-feature:nth-child(1) { background: linear-gradient(180deg, #fefdfb 0%, #f8f6f0 100%); border-left: 4px solid var(--accent); }
.landing-features-slider .landing-feature:nth-child(2) { background: linear-gradient(180deg, #fafcff 0%, #f0f4fa 100%); border-left: 4px solid #5a7ea6; }
.landing-features-slider .landing-feature:nth-child(3) { background: linear-gradient(180deg, #f8faf8 0%, #eef4ee 100%); border-left: 4px solid #4a7c59; }
.landing-features-slider .landing-feature:nth-child(4) { background: linear-gradient(180deg, #fdfaf8 0%, #f5ede8 100%); border-left: 4px solid #a67c5a; }
.landing-features-slider .landing-feature:nth-child(5) { background: linear-gradient(180deg, #fef8f8 0%, #f8eeee 100%); border-left: 4px solid #a65a6a; }
.landing-feature:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  border-color: rgba(139, 105, 20, 0.35);
}
.landing-feature-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(139, 105, 20, 0.12);
  color: var(--accent);
  font-size: 1.6rem;
}
.landing-feature h3 { margin: 0 0 0.5rem; font-size: 1.15rem; color: var(--text); }
.landing-feature p { margin: 0 auto; font-size: 0.95rem; color: var(--muted); line-height: 1.55; max-width: 420px; }

/* Slider buttons – centered vertically, professional accent */
.landing-features-slider .slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--card);
  color: var(--accent);
  font-size: 1.5rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  transition: background .2s, color .2s, border-color .2s, box-shadow .2s;
}
.landing-features-slider .slider-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(139, 105, 20, 0.35);
}
.landing-features-slider .slider-prev { left: 0; }
.landing-features-slider .slider-next { right: 0; }

/* Dots – visible on all screens */
.landing-features-slider .slider-dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-bottom: 0.25rem;
}
.landing-features-slider .slider-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  cursor: pointer;
  padding: 0;
  transition: background .2s, transform .2s;
}
.landing-features-slider .slider-dot:hover { background: var(--muted); }
.landing-features-slider .slider-dot.is-active {
  background: var(--accent);
  transform: scale(1.2);
}

/* Mobile: centered, touch-friendly */
@media (max-width: 768px) {
  .landing-features-slider { max-width: 100%; padding: 0 44px; margin-top: 1rem; }
  .landing-features-slider .slider-btn { width: 40px; height: 40px; font-size: 1.35rem; }
  .landing-features-slider .slider-prev { left: 4px; }
  .landing-features-slider .slider-next { right: 4px; }
  .landing-feature { padding: 1.5rem 1rem 1.25rem; min-height: 160px; }
  .landing-feature h3 { font-size: 1.05rem; }
  .landing-feature p { max-width: 100%; font-size: 0.9rem; }
}
@media (max-width: 480px) {
  .landing-features-slider { padding: 0 40px; }
  .landing-features-slider .slider-btn { width: 36px; height: 36px; font-size: 1.25rem; }
  .landing-features-slider .slider-prev { left: 2px; }
  .landing-features-slider .slider-next { right: 2px; }
}

.landing-themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.landing-theme-card {
  display: block; padding: 1.25rem; background: var(--card);
  border-radius: 8px; border: 1px solid var(--border);
  text-decoration: none; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.landing-theme-card:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.landing-theme-card h3 { margin: 0 0 0.5rem; font-size: 1.1rem; color: var(--accent); }
.landing-theme-card p { margin: 0 0 0.5rem; font-size: 0.9rem; color: var(--muted); line-height: 1.4; }
.landing-theme-count { font-size: 0.85rem; color: var(--accent); font-weight: 600; }

.landing-cta { background: var(--accent); color: #fff; text-align: center; padding: 2.5rem 1rem; }
.landing-cta-inner { max-width: 500px; margin: 0 auto; }
.landing-cta h2 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.landing-cta p { margin: 0 0 1.25rem; opacity: 0.95; }
.landing-cta .btn { margin: 0 0.35rem 0.35rem 0; }

/* About page */
.page-about { max-width: 720px; margin: 0 auto; }
.about-block { margin: 2rem 0; }
.about-block h2 { margin: 0 0 0.75rem; font-size: 1.25rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border); }
.about-block ul { padding-left: 1.5rem; margin: 0.5rem 0; }
.about-block li { margin: 0.4rem 0; }
.about-block a { color: var(--accent); text-decoration: none; }
.about-block a:hover { text-decoration: underline; color: var(--accent-hover, var(--accent)); }
.about-themes-list { list-style: none; padding-left: 0; }
.about-themes-list li { margin: 0.5rem 0; padding-left: 0; }
.about-themes-list a { color: var(--accent); text-decoration: none; }
.about-themes-list a:hover { text-decoration: underline; color: var(--accent-hover, var(--accent)); }

/* Footer nav */
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem 1.25rem; }
.footer-nav a { color: var(--accent); text-decoration: none; font-size: 0.95rem; }
.footer-nav a:hover { text-decoration: underline; }

/* Admin API docs page */
.admin-api-docs { max-width: 900px; }
.admin-api-docs h1 { margin-bottom: 0.5rem; }
.api-docs-intro { margin: 0 0 1.5rem; color: var(--muted); line-height: 1.6; }
.api-docs-intro code { background: var(--border); padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.9em; }
.api-docs-section { margin: 2rem 0; }
.api-docs-section h2 { font-size: 1.25rem; margin: 0 0 1rem; padding-bottom: 0.35rem; border-bottom: 2px solid var(--accent); }
.api-docs-block { margin: 1rem 0; }
.api-docs-block p { margin: 0.25rem 0; }
.api-endpoint {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem 1.25rem; margin: 1rem 0;
}
.api-endpoint p { margin: 0.5rem 0; font-size: 0.95rem; }
.api-endpoint ul { margin: 0.5rem 0; padding-left: 1.5rem; }
.api-method {
  display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px;
  font-size: 0.75rem; font-weight: 700; margin-right: 0.5rem;
}
.api-method-get { background: #d4edda; color: #155724; }
.api-method-post { background: #cce5ff; color: #004085; }
.api-method-put { background: #fff3cd; color: #856404; }
.api-method-delete { background: #f8d7da; color: #721c24; }
.api-auth-badge { margin-left: 0.5rem; font-size: 0.75rem; color: var(--accent); font-weight: 600; }
.api-auth-note { margin: 0 0 0.5rem; font-size: 0.9rem; color: var(--muted); }
.api-pre {
  background: #2d2d2d; color: #f8f8f2; padding: 1rem; border-radius: 6px;
  overflow-x: auto; font-size: 0.85rem; line-height: 1.45; margin: 0.5rem 0;
  white-space: pre-wrap; word-break: break-word;
}
.api-status-list { list-style: none; padding-left: 0; }
.api-status-list li { margin: 0.25rem 0; }
.api-status-list code { background: var(--border); padding: 0.1rem 0.35rem; border-radius: 3px; }

/* ========== Mobile responsive ========== */
@media (max-width: 768px) {
  body { font-size: 15px; overflow-x: hidden; }
  .site-header { padding: 0.5rem 0.75rem; position: relative; }
  .header-inner { gap: 0.5rem; }
  .logo { font-size: 1.1rem; }
  .logo .site-logo { max-height: 36px; max-width: 140px; }
  .nav-toggle-label {
    display: flex !important; align-items: center; justify-content: center;
    width: 44px; height: 44px; margin-left: auto;
    cursor: pointer; padding: 0; border: none; background: transparent;
    border-radius: 4px; position: relative; z-index: 101;
  }
  .nav-toggle-label:hover { background: var(--border); }
  .nav-toggle-label[aria-expanded="true"] .nav-toggle-icon {
    box-shadow: none; transform: rotate(45deg);
  }
  .nav-toggle-label[aria-expanded="true"] .nav-toggle-icon::after {
    content: ''; position: absolute; left: 0; top: 0;
    width: 22px; height: 2px; background: var(--text);
    transform: rotate(-90deg);
  }
  .nav-toggle-icon {
    display: block; width: 22px; height: 2px; background: var(--text);
    box-shadow: 0 -6px 0 var(--text), 0 6px 0 var(--text);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
  }
  /* Override base .site-header nav so menu is hidden until .menu-open */
  .site-header nav.site-nav {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--card); border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    flex-direction: column; padding: 0.75rem; gap: 0;
    z-index: 100; max-height: 70vh; overflow-y: auto;
  }
  .site-header.menu-open nav.site-nav { display: flex !important; }
  .site-nav a {
    display: block; padding: 0.75rem 1rem;
    border-radius: 4px;
  }
  .site-nav a:hover { background: var(--border); }
  .main-content { padding: 1rem 0.75rem; }
  .auth-card { margin: 1rem auto; padding: 1.25rem; max-width: none; margin-left: 0.75rem; margin-right: 0.75rem; }
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
  #recent-books .books-grid { grid-template-columns: repeat(2, 1fr); }
  .page-books .books-grid { grid-template-columns: repeat(2, 1fr); }
  .book-card .info { padding: 0.5rem; }
  .book-card .title { font-size: 0.95rem; }
  .book-card .meta { font-size: 0.8rem; }
  .book-badges { gap: 0.2rem; }
  .badge { font-size: 0.65rem; padding: 0.15rem 0.35rem; }
  .themes-list { gap: 0.75rem; }
  .themes-list a { padding: 0.75rem 1rem; font-size: 0.95rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .page-books-header { flex-direction: column; align-items: stretch; gap: 1rem; padding-bottom: 1rem; width: 100%; min-height: 0; }
  .page-books-header .toolbar-search,
  .page-books-header .toolbar-filters { flex: none; width: 100%; min-width: 0; }
  .page-books-header .toolbar-search input[type="search"] { width: 100%; min-width: 0; }
  .page-books-header .toolbar-search .toolbar-search-actions { display: flex; gap: 0.5rem; margin-top: 0.25rem; }
  .page-books-header .toolbar-search .toolbar-search-actions .btn { flex: 1; min-height: 44px; width: auto; }
  .page-books-header .toolbar-search .toolbar-search-actions button { width: auto; }
  /* Filters: Theme + Sort in a row, Apply full width below */
  .page-books-header .toolbar-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.75rem; padding: 0.75rem 1rem; background: rgba(0,0,0,.04); border-radius: 8px; border: 1px solid var(--border); }
  .page-books-header .toolbar-filters label { margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
  .page-books-header .toolbar-filters label select { width: 100%; min-width: 0; min-height: 44px; }
  .page-books-header .toolbar-filters button[type="submit"] { grid-column: 1 / -1; width: 100%; min-height: 44px; margin: 0; }
  .toolbar label { margin: 0.25rem 0; }
  form .toolbar button { width: 100%; }
  .book-detail { gap: 1.25rem; }
  .book-detail .cover-col { text-align: center; }
  .book-detail .cover-col img { max-width: 100%; height: auto; }
  .book-detail .meta-list li strong { width: 100px; }
  .book-actions { flex-direction: column; }
  .book-actions .btn { width: 100%; text-align: center; margin: 0.25rem 0; }
  .reader-page { margin: 0 -0.75rem; }
  .reader-toolbar { padding: 0.5rem 0.75rem; }
  .reader-title { font-size: 0.9rem; max-width: 140px; }
  .reader-frame-wrap { padding: 0.75rem; }
  .reader-frame { height: calc(100vh - 200px); min-height: 360px; }
  .reader-btn { padding: 0.35rem 0.5rem; font-size: 0.85rem; }
  .pagination { justify-content: center; }
  .container { max-width: none; }
  .profile-stats { display: flex; flex-wrap: wrap; gap: 0.75rem; }
  .profile-stats span { margin-right: 0.5rem; }
  /* Footer mobile */
  .site-footer { padding: 1.25rem 0.75rem; }
  .footer-inner { padding: 0 0.25rem; }
  .footer-brand { font-size: 1.05rem; margin-bottom: 0.35rem; }
  .footer-tagline { max-width: 100%; padding: 0 0.5rem; margin-bottom: 1rem; font-size: 0.9rem; line-height: 1.5; }
  .footer-nav { gap: 0.5rem 1rem; justify-content: center; }
  .footer-nav a { padding: 0.5rem 0.4rem; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: 0.95rem; }
  .footer-copy { margin-top: 1rem; font-size: 0.8rem; padding-top: 0.5rem; }
  .auth-page-wrap { padding: 1rem 0.75rem; }
  /* Touch-friendly form controls */
  form input[type="text"], form input[type="email"], form input[type="password"], form input[type="search"],
  form select { min-height: 44px; }
  form input[type="search"] { font-size: 16px; } /* prevents zoom on iOS */
  .book-detail .description { font-size: 1rem; line-height: 1.6; }
  .reviews-section form textarea { min-height: 88px; }
  /* Landing tablet */
  .landing-hero { padding: 2.5rem 1.25rem; }
  .landing-hero-title { font-size: 2rem; }
  .landing-section { padding: 2rem 1rem; }
  .landing-themes { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 480px) {
  .site-header { padding: 0.5rem 0.5rem; }
  .main-content { padding: 0.75rem 0.5rem; }
  .auth-card { margin: 0.75rem 0.5rem; padding: 1rem; }
  .books-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  #recent-books .books-grid { grid-template-columns: 1fr 1fr; }
  .page-books .books-grid { grid-template-columns: 1fr 1fr; }
  .book-card .title { font-size: 0.9rem; }
  h1 { font-size: 1.35rem; }
  .book-detail .meta-list li strong { width: 90px; font-size: 0.9rem; }
  table, .table-wrap table { min-width: 320px; font-size: 0.9rem; }
  th, td { padding: 0.5rem 0.4rem; }
  .btn { padding: 0.5rem 0.75rem; font-size: 0.95rem; }
  .auth-page-wrap { padding: 0.75rem 0.5rem; }
  .auth-page-wrap .auth-card { padding: 1.25rem; }
  /* Books page: filters stack on very small screens */
  .page-books-header .toolbar-filters { grid-template-columns: 1fr; gap: 0.5rem; padding: 0.75rem; }
  .page-books-header .toolbar-filters button[type="submit"] { grid-column: 1; }
  /* Footer small mobile */
  .site-footer { padding: 1rem 0.5rem; font-size: 0.85rem; }
  .footer-inner { padding: 0; }
  .footer-brand { font-size: 1rem; }
  .footer-tagline { padding: 0 0.25rem; margin-bottom: 0.75rem; font-size: 0.85rem; }
  .footer-nav {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 0.75rem;
    justify-content: center; justify-items: center; max-width: 280px; margin: 0 auto;
  }
  .footer-nav a { padding: 0.5rem 0.5rem; min-height: 44px; font-size: 0.9rem; }
  .footer-copy { margin-top: 0.75rem; padding-top: 0.5rem; font-size: 0.75rem; }
  /* Landing mobile */
  .landing-hero { padding: 2rem 1rem; }
  .landing-hero-title { font-size: 1.75rem; }
  .landing-hero-tagline { font-size: 1.05rem; }
  .landing-hero-desc { font-size: 0.95rem; }
  .landing-hero-actions { flex-direction: column; }
  .landing-hero-actions .btn { width: 100%; }
  .landing-section { padding: 1.5rem 0.75rem; }
  .landing-themes { grid-template-columns: 1fr; }
  .landing-cta { padding: 1.5rem 0.75rem; }
  .landing-cta .btn { display: block; width: 100%; margin: 0.5rem 0; }
  .reader-page { margin: 0 -0.5rem; }
  .reader-toolbar { padding: 0.5rem 0.5rem; flex-direction: column; align-items: stretch; }
  .reader-toolbar-left { order: 1; }
  .reader-toolbar-right { order: 2; justify-content: flex-start; }
  .reader-title { max-width: 100%; }
  .reader-frame { height: calc(100vh - 220px); min-height: 320px; }
  body.reader-fullscreen-on .reader-frame { height: calc(100vh - 80px); }
}

/* Admin dashboard grid on small screens */
@media (max-width: 768px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr) !important; gap: 0.75rem !important; }
  .admin-two-col { grid-template-columns: 1fr !important; gap: 1rem !important; }
}
@media (max-width: 480px) {
  .admin-stats { grid-template-columns: 1fr !important; }
}
