:root,
html[data-theme="light"] {
  color-scheme: light;
  --global-bg-color: #ffffff;
  --global-card-bg-color: #ffffff;
  --global-text-color: #111111;
  --global-text-color-light: #828282;
  --global-theme-color: #b509ac;
  --global-hover-color: #b509ac;
  --global-divider-color: rgba(0, 0, 0, 0.1);
  --global-footer-bg-color: #1c1c1d;
  --global-footer-text-color: #e8e8e8;
  --global-footer-link-color: #ffffff;
  --global-highlight-color: #b71c1c;
  --global-skill-tag-bg: rgba(181, 9, 172, 0.05);
  --global-profile-bg: linear-gradient(135deg, #f7e8f5, #efd8ec);
  --global-profile-fg: #b509ac;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --global-bg-color: #1c1c1d;
  --global-card-bg-color: #212529;
  --global-text-color: #e8e8e8;
  --global-text-color-light: #9a9a9a;
  --global-theme-color: #2698ba;
  --global-hover-color: #2698ba;
  --global-divider-color: #3a3a3c;
  --global-footer-bg-color: #e8e8e8;
  --global-footer-text-color: #1c1c1d;
  --global-footer-link-color: #000000;
  --global-highlight-color: #ff6b6b;
  --global-skill-tag-bg: rgba(38, 152, 186, 0.10);
  --global-profile-bg: linear-gradient(135deg, #2a3c44, #1f2d33);
  --global-profile-fg: #2698ba;
}

html { transition: background-color 0.2s ease, color 0.2s ease; }

html, body {
  background-color: var(--global-bg-color);
  color: var(--global-text-color);
  font-family: 'Roboto', sans-serif;
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.7;
}

body { padding-bottom: 80px; }

a {
  color: var(--global-theme-color);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}
a:hover { color: var(--global-theme-color); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
  font-family: 'Roboto Slab', serif;
  color: var(--global-text-color);
}

/* ─── Navigation ─── */
.navbar.navbar-light {
  background-color: var(--global-bg-color);
  border-bottom: 1px solid var(--global-divider-color);
  box-shadow: none;
  opacity: 0.97;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}
.navbar.navbar-light .navbar-brand,
.navbar.navbar-light .navbar-nav .nav-item .nav-link {
  color: var(--global-text-color);
}
.navbar.navbar-light .navbar-nav .nav-item .nav-link:hover,
.navbar.navbar-light .navbar-brand:hover {
  color: var(--global-hover-color);
  text-decoration: none;
}
.navbar.navbar-light .navbar-nav .nav-item.active > .nav-link {
  font-weight: 700;
  color: var(--global-theme-color);
}
.navbar-brand.title { font-weight: 300; font-size: 1.15rem; }

/* ─── Header (post-header) ─── */
.post-header { margin-top: 1.5rem; margin-bottom: 1rem; }
.post-title {
  font-weight: 300;
  font-size: 2.6rem;
  line-height: 1.2;
  margin-bottom: 0.15rem;
}
.post-title .font-weight-bold { font-weight: 700; }
.post-title .cv-pdf {
  float: right;
  font-size: 1.4rem;
  color: var(--global-text-color-light);
  margin-top: 0.6rem;
}
.post-title .cv-pdf:hover { color: var(--global-theme-color); }
.desc {
  color: var(--global-text-color-light);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}
.desc a { color: var(--global-text-color-light); border-bottom: 1px dashed var(--global-text-color-light); }
.desc a:hover { color: var(--global-theme-color); border-bottom-color: var(--global-theme-color); text-decoration: none; }

/* ─── About / Profile ─── */
.profile { width: 100%; }
.profile.float-right { margin-left: 2rem; margin-bottom: 1rem; }
@media (min-width: 576px) { .profile { width: 30%; max-width: 280px; } }
.profile img {
  border-radius: 0.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}
.about p { margin-bottom: 0.8rem; text-align: justify; }
.about a { color: var(--global-theme-color); border-bottom: 1px dashed var(--global-theme-color); }
.about a:hover { border-bottom-style: solid; text-decoration: none; }

/* ─── Section heading ─── */
.section-h2 {
  font-weight: 500;
  margin-top: 2rem;
  margin-bottom: 1.2rem;
}
.section-h2 a { color: inherit !important; border-bottom: none !important; }
.section-h2 a:hover { color: var(--global-theme-color) !important; text-decoration: none; }

/* Year heading (publications page) */
.year-h2 {
  font-weight: 500;
  font-size: 1.6rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--global-divider-color);
  color: var(--global-text-color);
}

/* ─── Publications (al-folio style) ─── */
.publications { margin-top: 1rem; }
.publications ol.bibliography {
  list-style: none;
  padding: 0;
  margin: 0;
}
.publications ol.bibliography > li {
  margin-bottom: 1.5rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--global-divider-color);
}
.publications ol.bibliography > li:last-child {
  border-bottom: none;
  margin-bottom: 0;
}
.publications .abbr { margin-bottom: 0.5rem; }
.publications .abbr abbr.badge {
  display: inline-block;
  width: 100%;
  max-width: 130px;
  padding: 0.4rem 0.5rem;
  background-color: var(--global-theme-color) !important;
  color: #fff !important;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 4px;
  text-decoration: none;
  text-align: center;
  letter-spacing: 0.02em;
}
.publications .award {
  display: inline-block;
  margin-top: 4px;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--global-highlight-color);
  color: var(--global-highlight-color);
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 4px;
  width: 100%;
  max-width: 130px;
  text-align: center;
  letter-spacing: 0.02em;
}
.publications .title {
  font-weight: 500;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--global-text-color);
}
.publications .author {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-top: 0.25rem;
}
.publications .author em {
  font-style: normal;
  border-bottom: 1px solid var(--global-text-color);
}
.publications .periodical {
  font-size: 0.92rem;
  color: var(--global-text-color);
  margin-top: 0.2rem;
}
.publications .periodical em { color: var(--global-text-color); }
.publications .periodical .note {
  color: var(--global-text-color-light);
  font-style: italic;
}
.publications .links { margin-top: 0.55rem; }
.publications .links a.btn {
  color: var(--global-text-color);
  border: 1px solid var(--global-text-color);
  padding: 0.18rem 0.85rem;
  margin-right: 0.35rem;
  margin-bottom: 0.3rem;
  font-size: 0.78rem;
  border-radius: 3px;
  box-shadow: none;
  background: transparent;
  transition: all 0.15s ease;
}
.publications .links a.btn:hover {
  color: var(--global-theme-color);
  border-color: var(--global-theme-color);
  text-decoration: none;
}

/* ─── CV-style cards ─── */
.cv { margin-bottom: 1.5rem; }
.cv .card {
  border: 1px solid var(--global-divider-color);
  border-radius: 0.5rem;
  box-shadow: none;
  margin-top: 0.75rem;
  padding: 1rem 1.1rem;
  background-color: var(--global-card-bg-color);
}
.cv .card-title {
  font-weight: 500;
  margin-bottom: 0.6rem;
  color: var(--global-text-color);
  font-size: 1.25rem;
}
.cv .list-group-item {
  background: inherit;
  border-color: var(--global-divider-color);
  padding: 0.85rem 0.25rem;
}
.cv .list-group-item:first-child { padding-top: 0.4rem; }
.cv .list-group-item:last-child { padding-bottom: 0.4rem; border-bottom: 0; }
.cv .badge.cv-date {
  display: inline-block;
  min-width: 110px;
  padding: 0.4rem 0.55rem;
  background-color: var(--global-theme-color) !important;
  color: #fff !important;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 4px;
  text-transform: uppercase;
  text-align: center;
}
.cv .item-title { font-weight: 500; color: var(--global-text-color); margin-bottom: 0.15rem; }
.cv .item-sub { color: var(--global-text-color-light); font-size: 0.92rem; }
.cv .item-sub i.fa-solid, .cv .item-sub i.fa-brands { width: 1rem; color: var(--global-text-color-light); }
.cv ul.tight { padding-left: 1.2rem; margin-top: 0.5rem; margin-bottom: 0; font-size: 0.92rem; }
.cv ul.tight li { margin-bottom: 0.2rem; }

/* ─── Service / Awards ─── */
.service-list, .awards-list { padding-left: 1.2rem; margin-bottom: 0; }
.service-list li, .awards-list li { margin-bottom: 0.35rem; line-height: 1.6; }
.award-tag {
  display: inline-block;
  margin-left: 0.4rem;
  color: var(--global-highlight-color);
  font-weight: 500;
  font-size: 0.85rem;
}

/* ─── Skills tags ─── */
.skill-row { margin-top: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; }
.skill-label {
  font-weight: 500;
  color: var(--global-text-color);
  min-width: 100px;
  font-size: 0.92rem;
}
.skill-tag {
  display: inline-block;
  padding: 0.18em 0.65em;
  font-size: 0.8rem;
  color: var(--global-text-color);
  background: var(--global-skill-tag-bg);
  border: 1px solid var(--global-divider-color);
  border-radius: 3px;
}

/* ─── Profile tile (dark-mode aware) ─── */
.profile-tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--global-profile-bg);
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Roboto Slab', Georgia, serif;
  font-size: 3.2rem;
  font-weight: 500;
  color: var(--global-profile-fg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
}

/* ─── Theme toggle button ─── */
.toggle-container {
  display: flex;
  align-items: center;
  margin-left: 0.6rem;
}
#light-toggle {
  background: transparent;
  border: none;
  color: var(--global-text-color);
  font-size: 1rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s ease, background-color 0.15s ease;
}
#light-toggle:hover { color: var(--global-theme-color); background-color: var(--global-divider-color); }
#light-toggle:focus { outline: none; box-shadow: 0 0 0 2px var(--global-theme-color); }
#light-toggle [data-theme-target] { display: none; }
html[data-theme-setting="system"] #light-toggle [data-theme-target="system"],
html[data-theme-setting="light"]  #light-toggle [data-theme-target="light"],
html[data-theme-setting="dark"]   #light-toggle [data-theme-target="dark"] {
  display: inline-block;
}
@media (max-width: 767.98px) {
  .toggle-container { margin-left: 0; margin-top: 0.4rem; justify-content: flex-end; }
}

/* ─── Social / Contact ─── */
.social { text-align: center; margin-top: 3rem; }
.social .contact-icons {
  font-size: 2.4rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1.6rem;
  line-height: 1;
}
.social .contact-icons a,
.social .contact-icons button.contact-link {
  color: var(--global-text-color);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: inherit;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  transition: color 0.2s ease;
}
.social .contact-icons a > i,
.social .contact-icons button.contact-link > i {
  display: block;
  font-size: 1em;
  line-height: 1;
  text-align: center;
}
.social .contact-icons a > svg,
.social .contact-icons button.contact-link > svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}
.social .contact-icons a:hover,
.social .contact-icons button.contact-link:hover { color: var(--global-theme-color); text-decoration: none; }
.social .contact-icons button.contact-link:focus { outline: none; color: var(--global-theme-color); }
.social .contact-note { font-size: 0.82rem; color: var(--global-text-color-light); margin-top: 0.4rem; }

/* ─── WeChat modal ─── */
.wechat-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1050;
  background-color: rgba(0, 0, 0, 0.72);
  align-items: center;
  justify-content: center;
  padding: 1rem;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.wechat-modal.is-open { display: flex; }
.wechat-modal__panel {
  position: relative;
  background-color: #ffffff;
  border-radius: 10px;
  padding: 1rem 1rem 0.75rem 1rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.wechat-modal__panel img {
  display: block;
  width: min(340px, 80vw);
  height: auto;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 4px;
}
.wechat-modal__caption {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: #555;
  letter-spacing: 0.04em;
}
.wechat-modal__close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background-color: #ffffff;
  color: #333;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: color 0.15s ease, transform 0.15s ease;
}
.wechat-modal__close:hover { color: var(--global-theme-color); transform: scale(1.06); }
.wechat-modal__close:focus { outline: none; box-shadow: 0 0 0 2px var(--global-theme-color); }

/* ─── Footer ─── */
footer.fixed-bottom {
  background-color: var(--global-footer-bg-color);
  font-size: 0.78rem;
}
footer.fixed-bottom .container {
  color: var(--global-footer-text-color);
  padding-top: 0.55rem;
  padding-bottom: 0.5rem;
  text-align: center;
}
footer.fixed-bottom a { color: var(--global-footer-link-color); }
footer.fixed-bottom a:hover { color: var(--global-theme-color); text-decoration: none; }

/* ─── Misc ─── */
.clearfix::after { content: ""; display: table; clear: both; }
hr.section-rule { border-top: 1px solid var(--global-divider-color); margin: 1.6rem 0; }
.page-intro { color: var(--global-text-color-light); font-size: 0.95rem; }
.page-intro em { color: var(--global-text-color-light); }

/* Small screens */
@media (max-width: 575.98px) {
  .profile.float-right { float: none !important; margin: 0 0 1rem 0; width: 60%; }
  .post-title { font-size: 2rem; }
  .post-title .cv-pdf { font-size: 1.2rem; }
  .cv .badge.cv-date { min-width: 90px; }
}
