:root {
  --bg: #faf8ff;
  --surface: #ffffff;
  --surface-2: #f3edff;
  --text: #292433;
  --muted: #81798f;
  --primary: #8b6acb;
  --primary-dark: #7250b5;
  --border: #e8e0f2;
  --shadow:
    0 12px 35px rgba(80, 55, 120, 0.08);
}
body.dark {
  --bg: #15121b;
  --surface: #201b29;
  --surface-2: #2a2335;
  --text: #f5f0fa;
  --muted: #aaa0b7;
  --primary: #b18be8;
  --primary-dark: #c4a2f2;
  --border: #393143;
  --shadow:
    0 12px 35px rgba(0, 0, 0, 0.28);
}
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  transition:
    background 0.25s ease,
    color 0.25s ease;
}
a {
  color: inherit;
  text-decoration: none;
}
/* ================================
HEADER
================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 72px;
  display: flex;
  align-items: center;
  padding: 0 6%;
  background:
    rgba(250, 248, 255, 0.88);
  backdrop-filter: blur(16px);
  border-bottom:
    1px solid var(--border);
}
body.dark .site-header {
  background:
    rgba(21, 18, 27, 0.88);
}
.logo {
  font-family: Georgia, serif;
  font-size: 27px;
  font-weight: 700;
  color: var(--primary);
}
.main-nav {
  display: flex;
  gap: 30px;
  margin-left: 55px;
}
.main-nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: 0.2s;
}
.main-nav a:hover,
.main-nav a.active {
  color: var(--primary);
}
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.theme-button {
  width: 38px;
  height: 38px;
  border:
    1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 17px;
}
.login-button {
  padding: 10px 17px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 700;
}
.user-menu {
  position: relative;
  display: none;
}
.user-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border:
    1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.header-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 700;
}
.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 190px;
  padding: 8px;
  border:
    1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: none;
}
.user-dropdown.show {
  display: block;
}
.user-dropdown a,
.user-dropdown button {
  width: 100%;
  display: block;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.user-dropdown a:hover,
.user-dropdown button:hover {
  background: var(--surface-2);
}
/* ================================
PAGE HEADER
================================ */
.page-header {
  max-width: 1200px;
  margin: 0 auto;
  padding:
    75px 25px 45px;
}
.section-label {
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
}
.page-header h1 {
  margin:
    10px 0;
  font-family: Georgia, serif;
  font-size:
    clamp(38px, 5vw, 55px);
}
.page-header p {
  margin: 0;
  max-width: 600px;
  color: var(--muted);
  line-height: 1.7;
}
/* ================================
NOVELS
================================ */
.novels-section {
  max-width: 1200px;
  margin: 0 auto;
  padding:
    0 25px 90px;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}
.result-info {
  color: var(--muted);
  font-size: 14px;
}
.result-info strong {
  color: var(--text);
}
#sortSelect {
  padding:
    10px 14px;
  border:
    1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
/* ================================
NOVEL GRID
================================ */
.novels-grid {
  display: grid;
  grid-template-columns:
    repeat(5, minmax(0, 1fr));
  gap: 22px;
}
.novel-card {
  display: block;
  overflow: hidden;
  border:
    1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.novel-card:hover {
  transform:
    translateY(-5px);
  box-shadow:
    0 18px 40px
    rgba(80, 55, 120, 0.13);
}
.novel-cover {
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  background:
    linear-gradient(
      135deg,
      #eee5ff,
      #d9c8fa
    );
  color: var(--primary);
  font-family: Georgia, serif;
  font-size: 48px;
  font-weight: 700;
}
body.dark .novel-cover {
  background:
    linear-gradient(
      135deg,
      #342a43,
      #493760
    );
}
.novel-info {
  padding: 15px;
}
.novel-title {
  display: block;
  margin-bottom: 7px;
  font-size: 15px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.novel-author {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}
.novel-meta {
  color: var(--primary);
  font-size: 12px;
  font-weight: 650;
}
/* ================================
PAGINATION
================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 45px;
}
.page-button {
  min-width: 38px;
  height: 38px;
  padding:
    0 10px;
  border:
    1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: 0.2s;
}
.page-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.page-button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}
.page-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* ================================
FOOTER
================================ */
footer {
  padding:
    45px 6%;
  border-top:
    1px solid var(--border);
  background: var(--surface);
}
.footer-logo {
  margin-bottom: 18px;
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-bottom: 18px;
}
.footer-links a {
  color: var(--muted);
  font-size: 13px;
}
.copyright {
  color: var(--muted);
  font-size: 12px;
}
/* ================================
TABLET
================================ */
@media (max-width: 1000px) {
  .novels-grid {
    grid-template-columns:
      repeat(4, minmax(0, 1fr));
  }
}
/* ================================
MOBILE
================================ */
@media (max-width: 680px) {
  .site-header {
    height: 64px;
    padding:
      0 18px;
  }
  .main-nav {
    display: none;
  }
  .page-header {
    padding:
      55px 18px 35px;
  }
  .novels-section {
    padding:
      0 18px 70px;
  }
  .novels-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
    gap: 15px;
  }
  .toolbar {
    align-items: flex-start;
  }
  #sortSelect {
    max-width: 150px;
  }
  .novel-info {
    padding: 12px;
  }
  .novel-title {
    font-size: 13px;
  }
  .novel-author,
  .novel-meta {
    font-size: 11px;
  }
}
/* Common footer */
.site-footer, footer {
  padding: 36px 5% 28px;
  border-top: 1px solid var(--border);
  background: var(--card, var(--surface, #fff));
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.footer-logo {
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}
.footer-slogan {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.footer-social {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-social-link {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.footer-social-link:hover { color: var(--primary); }
.footer-disclaimer {
  margin: 0 auto;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  max-width: 700px;
  opacity: 0.9;
}
@media (max-width: 600px) {
  .footer-inner { flex-direction: column; text-align: center; }
  .footer-social { justify-content: center; }
}

/* Header search */
.header-search {
  flex: 1;
  max-width: 280px;
  margin: 0 12px;
  position: relative;
  min-width: 120px;
}
.header-search input {
  width: 100%;
  height: 38px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface, var(--card, #fff));
  color: var(--text);
  outline: none;
  font-size: 13px;
}
.header-search input:focus {
  border-color: var(--primary);
}
.header-search button {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  width: 30px;
  height: 30px;
}
@media (max-width: 680px) {
  .header-search {
    max-width: none;
    flex: 1;
    margin: 0 8px;
    min-width: 0;
  }
  .header-search input {
    height: 36px;
    font-size: 12px;
    padding-left: 10px;
  }
}

@media (max-width: 680px) {
  .site-header, .member-header, .reader-header {
    height: auto !important;
    min-height: 56px;
    padding: 8px 12px !important;
    flex-wrap: wrap;
    gap: 8px;
  }
  .header-search {
    flex: 1 1 100%;
    max-width: none !important;
    margin: 0 !important;
    order: 10;
  }
  .main-nav, nav { display: none; }
}



.site-logo {
  display: flex !important;
  align-items: center;
  gap: 10px;
  text-decoration: none !important;
  color: inherit;
  flex-shrink: 0;
  visibility: visible !important;
  opacity: 1 !important;
}
.site-logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--primary, #8b5cf6);
  color: #fff !important;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  font-family: Georgia, serif;
  flex-shrink: 0;
}
.site-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.site-logo-text strong {
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary, #8b5cf6) !important;
}
.site-logo-text small {
  font-size: 11px;
  color: var(--muted, #81798f);
  font-weight: 500;
  margin-top: 1px;
}
@media (max-width: 680px) {
  .site-logo-icon { width: 34px; height: 34px; font-size: 16px; }
  .site-logo-text strong { font-size: 18px; }
  .site-logo-text small { font-size: 10px; }
}


/* ===== LOGO kiểu thiết kế (star + serif) ===== */
.site-logo {
  display: flex !important;
  align-items: center;
  gap: 10px;
  text-decoration: none !important;
  color: inherit;
  flex-shrink: 0;
  visibility: visible !important;
  opacity: 1 !important;
}
.site-logo-mark {
  font-size: 26px;
  line-height: 1;
  color: var(--primary, #8b6acb);
  filter: drop-shadow(0 0 6px rgba(139, 106, 203, 0.35));
}
.site-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.site-logo-name {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 26px;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.2px;
  color: var(--primary, #8b6acb) !important;
  background: linear-gradient(135deg, #9b7ad8 0%, #7c5cbf 50%, #a78bfa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
/* fallback if gradient text not supported */
@supports not (-webkit-background-clip: text) {
  .site-logo-name {
    color: var(--primary, #8b6acb) !important;
    -webkit-text-fill-color: unset;
  }
}
.site-logo-slogan {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 500;
  font-style: normal;
  color: var(--muted, #81798f) !important;
  -webkit-text-fill-color: var(--muted, #81798f);
  margin-top: 2px;
  letter-spacing: 0.2px;
}
@media (max-width: 680px) {
  .site-logo-mark { font-size: 22px; }
  .site-logo-name { font-size: 20px; }
  .site-logo-slogan { font-size: 10px; }
}
