:root {
  --primary: #8b5cf6;
  --primary-dark: #7c3aed;
  --bg: #f7f4fc;
  --card: #ffffff;
  --text: #272331;
  --muted: #81798e;
  --border: #e8e1ef;
}
body.dark {
  --bg: #15121c;
  --card: #211c2b;
  --text: #f5f2fa;
  --muted: #aaa1b5;
  --border: #393044;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
}
a {
  color: inherit;
  text-decoration: none;
}
/* HEADER */
.site-header {
  height: 70px;
  padding: 0 5%;
  display: flex;
  align-items: center;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo {
  color: var(--primary);
  font-size: 25px;
  font-weight: 800;
}
nav {
  display: flex;
  gap: 28px;
  margin-left: 55px;
}
nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
#themeToggle {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
#loginLink,
#memberLink {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}
/* MAIN */
main {
  width: min(1050px, 92%);
  margin: 35px auto 80px;
}
/* HERO */
.story-hero {
  padding: 30px;
  display: flex;
  gap: 30px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
}
.story-cover {
  width: 220px;
  height: 300px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background:
    linear-gradient(
      135deg,
      #c4b5fd,
      #7c3aed
    );
  color: white;
  font-size: 80px;
  font-weight: 800;
}
.story-info {
  padding-top: 10px;
}
.tags {
  display: flex;
  gap: 7px;
}
.tags span {
  padding: 5px 9px;
  border-radius: 7px;
  background: rgba(139,92,246,.1);
  color: var(--primary);
  font-size: 11px;
}
.story-info h1 {
  margin: 14px 0 7px;
  font-size: 34px;
}
.author {
  color: var(--muted);
  font-size: 13px;
}
.story-meta {
  display: flex;
  gap: 15px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 12px;
}
.description {
  max-width: 650px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}
.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 23px;
}
.primary-button,
.secondary-button,
.follow-button {
  padding: 11px 17px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.primary-button {
  background: var(--primary);
  color: white;
}
.secondary-button,
.follow-button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}
.follow-button.active {
  border-color: var(--primary);
  color: var(--primary);
}
/* SECTION */
.section {
  margin-top: 40px;
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
.section-heading h2 {
  margin: 0;
  font-size: 20px;
}
.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}
#chapterSearch {
  width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  outline: none;
}
/* CHAPTER */
.chapter-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.chapter-item {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: .15s;
}
.chapter-item:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.chapter-number {
  font-weight: 700;
  font-size: 13px;
}
.chapter-title {
  color: var(--muted);
  font-size: 11px;
}
/* COMMENTS */
.comments-section {
  padding-top: 5px;
}
.comment-form {
  display: flex;
  gap: 10px;
  margin: 18px 0;
}
.comment-form textarea {
  min-height: 75px;
  flex: 1;
  padding: 12px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  outline: none;
}
.comment-form button {
  height: 42px;
  padding: 0 17px;
  align-self: flex-end;
  border: none;
  border-radius: 9px;
  background: var(--primary);
  color: white;
  cursor: pointer;
}
.comment {
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}
.comment strong {
  font-size: 13px;
}
.comment p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}
/* RECOMMEND */
.recommend-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.recommend-card {
  padding: 14px;
  display: flex;
  gap: 13px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 13px;
}
.recommend-cover {
  width: 60px;
  height: 75px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: linear-gradient(
    135deg,
    #c4b5fd,
    #8b5cf6
  );
  color: white;
  font-size: 22px;
  font-weight: 800;
}
.recommend-card strong,
.recommend-card span {
  display: block;
}
.recommend-card strong {
  font-size: 14px;
}
.recommend-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}
/* FOOTER */
footer {
  padding: 30px 5%;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 12px;
}
/* MOBILE */
@media (max-width: 700px) {
  nav {
    display: none;
  }
  .story-hero {
    flex-direction: column;
    padding: 20px;
  }
  .story-cover {
    width: 150px;
    height: 210px;
    margin: auto;
    font-size: 55px;
  }
  .story-info h1 {
    font-size: 26px;
  }
  .chapter-list {
    grid-template-columns: 1fr;
  }
  .recommend-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 500px) {
  .story-actions {
    flex-direction: column;
  }
  .primary-button,
  .secondary-button,
  .follow-button {
    text-align: center;
  }
  .comment-form {
    flex-direction: column;
  }
  .comment-form button {
    align-self: stretch;
  }
}
/* 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; }
}
