:root {
  --bg: #f7f5fb;
  --card: #ffffff;
  --text: #28232f;
  --muted: #81798d;
  --border: #e8e3ef;
  --soft: #f1edf8;
  --primary: #8b63d9;
  --primary-dark: #7048bf;
  --green: #3e9451;
  --shadow: 0 8px 30px rgba(80, 50, 120, .07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

/* HEADER */

.member-header {
  height: 65px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 5%;
  gap: 35px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.logo {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo span {
  width: 35px;
  height: 35px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
}

.member-header nav {
  display: flex;
  gap: 25px;
}

.member-header nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
}

.member-header nav a:hover {
  color: var(--primary);
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-button {
  border: 0;
  background: var(--soft);
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.mini-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* MAIN */

.member-container {
  width: min(1050px, 92%);
  margin: 30px auto 60px;
  display: grid;
  gap: 20px;
}

/* PROFILE */

.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 17px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.profile-main {
  display: flex;
  align-items: center;
  gap: 18px;
}

.avatar-wrapper {
  position: relative;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.default-avatar {
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-size: 35px;
  font-weight: 800;
}

#profileAvatar {
  display: none;
}

.avatar-upload {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.avatar-upload input {
  display: none;
}

.username-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.username-line h1 {
  margin: 0;
  font-size: 25px;
}

.member-badge {
  color: var(--primary);
  background: var(--soft);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
}

.profile-info p {
  color: var(--muted);
  font-size: 13px;
  margin: 7px 0 12px;
}

.outline-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.outline-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.profile-stats {
  border-top: 1px solid var(--border);
  margin-top: 22px;
  padding-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  text-align: center;
}

.profile-stats div {
  border-right: 1px solid var(--border);
}

.profile-stats div:last-child {
  border-right: 0;
}

.profile-stats strong,
.profile-stats span {
  display: block;
}

.profile-stats strong {
  font-size: 18px;
}

.profile-stats span {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

/* SECTION */

.section-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 17px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.level-box {
  background: var(--soft);
  border-radius: 10px;
  padding: 8px 14px;
  text-align: center;
}

.level-box span,
.level-box strong {
  display: block;
}

.level-box span {
  color: var(--muted);
  font-size: 9px;
}

.level-box strong {
  color: var(--primary);
  font-size: 20px;
}

/* XP */

.xp-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 7px;
}

.xp-info span {
  color: var(--muted);
}

.xp-bar {
  height: 8px;
  background: var(--soft);
  border-radius: 20px;
  overflow: hidden;
}

.xp-bar div {
  height: 100%;
  background: var(--primary);
  border-radius: 20px;
}

.mission-list {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.mission {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--border);
  padding: 11px;
  border-radius: 10px;
}

.mission-icon {
  width: 37px;
  height: 37px;
  border-radius: 8px;
  background: var(--soft);
  display: grid;
  place-items: center;
}

.mission-info {
  flex: 1;
}

.mission-info strong,
.mission-info span {
  display: block;
}

.mission-info strong {
  font-size: 12px;
}

.mission-info span {
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
}

.mission-reward {
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.claim-button {
  border: 1px solid var(--primary);
  color: var(--primary);
  background: transparent;
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 11px;
  font-weight: 700;
}

.claim-button:hover {
  background: var(--primary);
  color: white;
}

.claim-button.claimed {
  background: var(--soft);
  border-color: var(--border);
  color: var(--muted);
  cursor: default;
}

/* REWARDS */

.reward-category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.reward-category {
  border: 1px solid var(--border);
  border-radius: 15px;
  overflow: hidden;
  background: var(--card);
}

.reward-category-header {
  padding: 17px;
  background: var(--soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reward-price {
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.reward-category-header h3 {
  margin: 5px 0 0;
  font-size: 16px;
}

.reward-count {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.reward-items {
  display: flex;
  flex-direction: column;
}

.reward-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-top: 1px solid var(--border);
}

.reward-item-icon {
  width: 45px;
  height: 45px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--soft);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 20px;
}

.reward-item-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reward-item-info {
  flex: 1;
  min-width: 0;
}

.reward-item-info strong {
  display: block;
  font-size: 13px;
}

.reward-item-info span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.exchange-button {
  flex-shrink: 0;
  padding: 7px 12px;
  border: 1px solid var(--primary);
  border-radius: 7px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.exchange-button:hover {
  background: var(--primary);
  color: white;
}

/* HISTORY */

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
}

.history-cover {
  width: 42px;
  height: 52px;
  background: var(--soft);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--primary);
  font-weight: bold;
}

.history-info {
  flex: 1;
}

.history-info strong,
.history-info span {
  display: block;
}

.history-info strong {
  font-size: 13px;
}

.history-info span {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
}

/* FOLLOWING */

.following-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.following-card {
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.following-cover {
  width: 43px;
  height: 55px;
  background: var(--soft);
  border-radius: 6px;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: bold;
}

.following-card strong,
.following-card span {
  display: block;
}

.following-card strong {
  font-size: 12px;
}

.following-card span {
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}

/* COIN */

.coin-history {
  display: grid;
}

.coin-history > div {
  display: flex;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.coin-history > div:last-child {
  border-bottom: 0;
}

.plus {
  color: var(--green);
}

/* MODAL */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 30, .5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal.active {
  display: flex;
}

.modal-box {
  width: min(430px, 100%);
  background: var(--card);
  border-radius: 15px;
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
}

.modal-header button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 25px;
}

.modal-box label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-box input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  margin-bottom: 15px;
}

.primary-button {
  width: 100%;
  border: 0;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  padding: 10px;
  font-weight: 700;
}

/* FOOTER */

footer {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 20px;
}

/* DARK */

body.dark {
  --bg: #17141d;
  --card: #211d29;
  --text: #f2edf8;
  --muted: #aaa1b7;
  --border: #37303f;
  --soft: #2b2534;
}

/* MOBILE */

@media (max-width: 800px) {

  .member-header {
    padding: 0 4%;
    gap: 15px;
  }

  .member-header nav {
    display: none;
  }

  .member-container {
    width: 94%;
    margin-top: 18px;
  }

  .profile-main {
    align-items: flex-start;
  }

  .profile-avatar {
    width: 78px;
    height: 78px;
  }

  .profile-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px 0;
  }

  .profile-stats div:nth-child(2) {
    border-right: 0;
  }

  .following-grid,
  .reward-category-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 500px) {

  .section-card,
  .profile-card {
    padding: 16px;
  }

  .username-line {
    flex-wrap: wrap;
  }

  .username-line h1 {
    font-size: 20px;
  }

  .mission {
    flex-wrap: wrap;
  }

  .mission-info {
    min-width: calc(100% - 60px);
  }

  .mission-reward {
    margin-left: 48px;
  }

  .claim-button {
    margin-left: auto;
  }

  .reward-item {
    gap: 9px;
  }

  .exchange-button {
    padding: 7px 9px;
  }
}
/* =========================
   MEMBER SIDEBAR LAYOUT
========================= */
.member-layout {
  width: min(1150px, 94%);
  margin: 30px auto 60px;
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 22px;
  align-items: start;
}

.member-sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 14px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 80px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  overflow: hidden;
}

.sidebar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user strong {
  display: block;
  font-size: 14px;
}

.sidebar-user span {
  color: var(--muted);
  font-size: 11px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: var(--soft);
  color: var(--primary);
  font-weight: 700;
}

.sidebar-logout {
  margin-top: 10px;
  color: #c44 !important;
}

.sidebar-logout:hover {
  background: #fde8e8 !important;
}

/* member-container inside layout */
.member-layout .member-container {
  width: 100%;
  margin: 0;
  display: grid;
  gap: 20px;
}

@media (max-width: 860px) {
  .member-layout {
    grid-template-columns: 1fr;
  }
  .member-sidebar {
    position: static;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-link {
    width: auto;
  }
}

/* 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; }
}
