/* ==========================================================================
   1. Global Styles
   ========================================================================== */
:root {
  --bg: #fbfbfd;
  --bg-top: #eee7fb;
  --surface: #ffffff;
  --surface-soft: #f7f8fb;
  --image-surface: #ffffff;
  --text: #28242c;
  --text-strong: #201c27;
  --muted: #514b59;
  --line: #e8e3ee;
  --image-line: #ece8f1;
  --accent: #5a3f9f;
  --accent-strong: #3f2a7a;
  --accent-soft: #f2edf9;
  --accent-wash: #fbf9ff;
  --highlight-fade: rgba(255, 255, 255, 0.75);
  --badge-bg: #f6f2fb;
  --badge-border: #e0d7ef;
  --badge-text: #58398e;
  --footer-text: #77717f;
  --visitor-map-bg: var(--bg);
  --visitor-map-border: var(--bg-top);
  --shadow: 0 12px 28px rgba(53, 43, 72, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15131a;
  --bg-top: #271a38;
  --surface: #1d1a24;
  --surface-soft: #23202b;
  --image-surface: #ffffff;
  --text: #edeaf2;
  --text-strong: #fbf8ff;
  --muted: #c7bfce;
  --line: #373141;
  --image-line: #4b4358;
  --accent: #c4a7ff;
  --accent-strong: #e1d2ff;
  --accent-soft: #30253e;
  --accent-wash: #211b2a;
  --highlight-fade: rgba(29, 26, 36, 0.75);
  --badge-bg: #30253e;
  --badge-border: #5a4a73;
  --badge-text: #d9c7ff;
  --footer-text: #aaa1b4;
  --visitor-map-bg: var(--bg);
  --visitor-map-border: var(--bg-top);
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, var(--bg-top) 0, var(--bg) 320px),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body,
td,
th,
tr,
p,
a,
button {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 16px;
  line-height: 1.62;
}

p {
  margin: 0 0 14px;
}

.page-shell {
  max-width: 1120px !important;
  width: 100% !important;
  padding: 42px 30px 34px;
}

.page-shell > tbody > tr > td {
  padding: 0 4px !important;
}

strong {
  font-family: inherit;
  font-size: inherit;
}

/* Links */
a,
a:visited,
a:focus {
  color: var(--accent) !important;
  text-decoration: none;
  outline: none;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

a:hover {
  color: var(--accent-strong) !important;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid rgba(90, 63, 159, 0.35);
  outline-offset: 3px;
  border-radius: 6px;
}

.theme-toggle {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 78px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-strong);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(53, 43, 72, 0.08);
  cursor: pointer;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.theme-toggle:hover {
  color: var(--accent-strong);
  border-color: var(--accent);
  background: var(--surface);
}

.theme-toggle-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset -4px -2px 0 var(--surface);
}

html[data-theme="dark"] .theme-toggle-icon {
  box-shadow: 0 0 0 2px rgba(196, 167, 255, 0.18);
}


/* ==========================================================================
   2. Profile Section
   ========================================================================== */
.bio-table {
  margin-bottom: 8px;
}

.bio-text {
  padding: 18px 22px 18px 8px !important;
}

.bio-photo {
  padding: 18px 8px 18px 26px !important;
  text-align: center;
}

.bio-photo a {
  display: inline-block;
  width: min(100%, 190px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 0;
  line-height: 0;
}

.name {
  padding-top: 12px;
  margin: 0 0 18px;
  color: var(--text-strong);
  font-size: 38px;
  line-height: 1.12;
}

.name span {
  font-family: inherit !important;
}

.name .name-en {
  font-family: "Snell Roundhand", "Apple Chancery", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif !important;
  font-size: 1em;
  font-weight: 500;
}

.name .name-cn {
  margin-left: 10px;
  font-family: "Xingkai SC", "STXingkai", "HanziPen SC", "Kaiti SC", "STKaiti", "KaiTi", "楷体", "DFKai-SB", "LXGW WenKai", "FangSong", "仿宋", cursive, serif !important;
  font-size: 1em;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.bio-text p:not(.name):not(.contact-links) {
  max-width: 710px;
  color: var(--text);
}

.contact-links {
  margin-top: 18px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.contact-links a {
  display: inline-block;
  padding: 1px 4px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.45;
}

img.hoverZoomLink {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  border: 0;
  border-radius: 0 !important;
  box-shadow: none;
  object-fit: cover;
}


/* ==========================================================================
   3. Section Headings
   ========================================================================== */
section.rebio {
  margin-top: 36px !important;
  border-top: 1px solid var(--line);
}

.rebio td {
  padding: 22px 12px 10px !important;
}

.rebio p {
  max-width: 900px;
  margin-top: 8px;
  margin-bottom: 0;
  color: var(--muted);
}

.rebio p span {
  font-size: 14px !important;
  line-height: 1.55;
}

h2 {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  color: var(--text-strong);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 21px;
  font-weight: 720;
  letter-spacing: 0;
  line-height: 1.25;
}

h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), rgba(232, 227, 238, 0));
}


/* ==========================================================================
   4. Paper List Layout, Images, Videos
   ========================================================================== */
.paper-entry {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 22px;
  position: relative;
  margin: 4px 0 10px;
  padding: 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.paper-entry:hover {
  background-color: var(--accent-wash);
  border-color: var(--line);
  transform: translateY(-1px);
}

.paper_image_col {
  flex: 0 0 39% !important;
  position: relative;
  display: flex !important;
  align-items: center;
  justify-content: center;
  max-width: 39%;
  min-height: 210px;
  padding: 8px;
  overflow: hidden;
  border: 1px solid var(--image-line);
  border-radius: 8px;
  background: var(--image-surface);
}

.paper_teaser {
  position: relative;
  z-index: 1;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  border-radius: 6px;
  object-fit: contain !important;
}

.paper_stay {
  position: absolute;
  z-index: 5;
  top: 8px;
  right: 8px;
  bottom: 8px;
  left: 8px;
  opacity: 0;
  border-radius: 6px;
  background-color: var(--image-surface);
  transition: opacity 0.28s ease-in-out;
}

.paper_stay img {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  object-fit: contain;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.paper-entry:hover .paper_stay {
  opacity: 1;
}

.paper-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 200px;
  padding-left: 0;
  gap: 7px;
}

.paper-body.highlight {
  padding: 12px 14px;
  border-left: 3px solid rgba(90, 63, 159, 0.55);
  border-radius: 8px;
  background: linear-gradient(90deg, var(--accent-soft), var(--highlight-fade));
}


/* ==========================================================================
   5. Video Modal
   ========================================================================== */
.video-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: rgba(18, 15, 24, 0.88);
}

.video-modal-content {
  position: relative;
  width: min(88vw, 940px);
}

#modalVideo {
  border-radius: 8px !important;
  background: #000000;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.video-modal-close {
  position: absolute;
  top: -48px;
  right: 0;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: #ffffff;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 32px;
  line-height: 1;
  transition: background-color 160ms ease;
}

.video-modal-close:hover {
  background: rgba(255, 255, 255, 0.22);
}


/* ==========================================================================
   6. Paper Typography
   ========================================================================== */
.papertitle {
  display: block;
  color: var(--text-strong);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 720;
  line-height: 1.34;
}

.paper-body a:hover .papertitle {
  color: var(--accent-strong);
}

.authors {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
  line-height: 1.45;
}

.venue {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.venue-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px;
  border: 1px solid var(--badge-border);
  border-radius: 6px;
  color: var(--badge-text);
  background-color: var(--badge-bg);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 720;
  line-height: 1;
}

.tldr {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

span.highlight {
  padding: 0 4px;
  border-radius: 4px;
  background-color: var(--accent-soft);
}


/* ==========================================================================
   7. Visitor / Footer
   ========================================================================== */
.visitor-map {
  margin-top: 72px !important;
  text-align: center;
}

.visitor-map-widget {
  display: inline-block;
  padding: 8px;
  border: 1px solid var(--visitor-map-border);
  border-radius: 8px;
  background: var(--visitor-map-bg);
  transition: background-color 180ms ease, filter 180ms ease;
}

html[data-theme="dark"] .visitor-map-widget > :not(script) {
  filter: invert(0.92) hue-rotate(180deg) saturate(0.85) brightness(0.82);
}

.footer-table p {
  margin-top: 18px;
  color: var(--footer-text) !important;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px !important;
  line-height: 1.5;
}

.footer-table span,
.footer-table strong {
  font-size: inherit !important;
}


/* ==========================================================================
   8. Mobile / Responsive
   ========================================================================== */
@media (max-width: 700px) {
  body {
    padding: 0 12px;
  }

  body,
  td,
  th,
  tr,
  p,
  a,
  button {
    font-size: 15.5px;
  }

  .page-shell {
    padding: 24px 0 28px;
  }

  .theme-toggle {
    top: 10px;
    right: 12px;
    min-width: 70px;
    padding: 6px 9px;
    font-size: 12px;
  }

  .bio-row {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
  }

  .bio-text,
  .bio-photo {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    padding: 8px !important;
  }

  .bio-photo a {
    width: 132px;
  }

  .name {
    padding-top: 8px;
    font-size: 30px;
    text-align: center;
  }

  .bio-text p:not(.name):not(.contact-links) {
    max-width: 100%;
  }

  section.rebio {
    margin-top: 30px !important;
  }

  .rebio td {
    padding: 20px 8px 8px !important;
  }

  h2 {
    font-size: 19px;
  }

  .paper-entry {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 10px;
  }

  .paper_image_col {
    flex: 0 0 auto !important;
    width: 100%;
    max-width: 100%;
    min-height: 220px;
    margin-bottom: 0;
    padding: 10px;
  }

  .paper_teaser {
    width: 100%;
    height: 100% !important;
  }

  .paper-body {
    min-width: 0;
    width: 100%;
    padding-left: 0;
    margin-left: 0;
  }

  .paper-body.highlight {
    padding: 12px;
  }

  .video-modal {
    padding: 16px;
  }

  .video-modal-content {
    width: 94vw;
  }

  .video-modal-close {
    top: -44px;
  }

  .visitor-map {
    margin-top: 54px !important;
  }
}
