/* =========================================================
   Qixin Xiao — personal site
   Clean academic style with light / dark themes
   ========================================================= */

:root {
  --bg: #ffffff;
  --bg-soft: #f5f6f8;
  --ink: #111827;
  --text: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1d5fc4;
  --accent-hover: #164a99;
  --accent-soft: rgba(29, 95, 196, 0.08);
  --nav-bg: rgba(255, 255, 255, 0.86);
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06);

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 60px;
  color-scheme: only light;
  background: var(--bg);
}

[data-theme="dark"] {
  --bg: #0f1216;
  --bg-soft: #171b21;
  --ink: #e8edf2;
  --text: #c2cad3;
  --muted: #8a95a1;
  --line: #262c34;
  --accent: #74a9ff;
  --accent-hover: #a3c6ff;
  --accent-soft: rgba(116, 169, 255, 0.12);
  --nav-bg: rgba(15, 18, 22, 0.86);
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 20px); }

body {
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

strong { color: var(--ink); font-weight: 600; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 28px; }

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: var(--nav-bg);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.brand { color: var(--ink); font-weight: 600; font-size: 16px; }
.brand:hover { color: var(--ink); text-decoration: none; }

.nav-right { display: flex; align-items: center; gap: 6px; height: 100%; }

.nav-links { display: flex; align-items: center; height: 100%; gap: 2px; }
.nav-links a {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  font-size: 14px;
  color: var(--text);
  padding: 0 11px;
}
.nav-links a:hover { color: var(--accent); text-decoration: none; }
.nav-links a.active { color: var(--accent); }
.nav-links a.active::after {
  content: "";
  position: absolute;
  left: 11px; right: 11px; bottom: -1px;
  height: 2px;
  background: var(--accent);
}
.nav-links .nav-cv {
  height: auto;
  margin-left: 6px;
  padding: 4px 12px;
  font-weight: 500;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.nav-links .nav-cv:hover { border-color: var(--accent); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  margin-left: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .i-sun { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }

.nav-toggle { display: none; background: none; border: 0; width: 34px; height: 34px; cursor: pointer; position: relative; }
.nav-toggle span { position: absolute; left: 8px; right: 8px; height: 1.5px; background: var(--ink); transition: transform .25s, top .25s; }
.nav-toggle span:first-child { top: 13px; }
.nav-toggle span:last-child { top: 20px; }
.nav-toggle[aria-expanded="true"] span:first-child { top: 16.5px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child { top: 16.5px; transform: rotate(-45deg); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 60px;
  padding-top: 48px;
}

/* ---------- sidebar ---------- */
.sidebar {
  top: calc(var(--nav-h) + 36px);
  align-self: start;
}
@media (min-height: 940px) {
  .sidebar { position: sticky; }
}

.avatar {
  position: relative;
  width: 172px;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
  margin-bottom: 22px;
}
.avatar img,
.avatar-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar img { position: relative; z-index: 1; }
.avatar-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 40px;
  font-weight: 600;
  color: var(--muted);
}

.logos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 230px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.logos a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.logos a:hover { color: var(--accent); text-decoration: none; }
.logos img {
  width: 50px; height: 50px;
  object-fit: contain;
  padding: 3px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  transition: transform .15s, border-color .15s;
}
.logos a:hover img { transform: translateY(-2px); border-color: var(--accent); }

.name {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.3px;
  margin-bottom: 10px;
}

.affil { font-size: 14px; line-height: 1.55; margin-bottom: 12px; }
.affil p:first-child strong { font-weight: 400; color: var(--text); }

.tagline {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.tagline span { white-space: nowrap; }

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 4px;
}
.status svg { flex-shrink: 0; width: 15px; height: 15px; }
.status a { color: var(--text); }
.status a:hover { color: var(--accent); }

.side-links { list-style: none; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.side-links li + li { margin-top: 2px; }
.side-links a { display: inline-block; font-size: 14px; font-weight: 500; padding: 2px 0; }

/* ---------- sections ---------- */
.section { padding-bottom: 52px; }

.sec-head { margin-bottom: 18px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.sec-head h2 {
  font-size: 21px;
  font-weight: 650;
  color: var(--ink);
  letter-spacing: -.2px;
}

.prose p + p { margin-top: 14px; }
.hl { font-style: normal; color: var(--ink); font-weight: 600; }

/* ---------- news ---------- */
.news { list-style: none; }
.news li {
  --tile: linear-gradient(135deg, rgba(96, 165, 250, 0.28), rgba(29, 78, 216, 0.1));
  --glow: rgba(37, 99, 235, 0.3);
  position: relative;
  display: grid;
  grid-template-columns: 34px 44px 1fr;
  align-items: start;
  gap: 12px;
  padding: 8px 0;
  font-size: 14.5px;
}
.news li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 40px;
  bottom: -6px;
  width: 2px;
  border-radius: 1px;
  background: var(--line);
}
.news .n-pos { --tile: linear-gradient(135deg, rgba(167, 139, 250, 0.3), rgba(109, 40, 217, 0.1)); --glow: rgba(124, 58, 237, 0.3); }
.news .n-pre { --tile: linear-gradient(135deg, rgba(253, 186, 116, 0.34), rgba(234, 88, 12, 0.1)); --glow: rgba(234, 88, 12, 0.28); }
.news .n-acc { --tile: linear-gradient(135deg, rgba(110, 231, 183, 0.32), rgba(5, 150, 105, 0.1)); --glow: rgba(5, 150, 105, 0.28); }
.n-ico {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 11px;
  background: var(--tile);
  box-shadow: 0 6px 14px -8px var(--glow);
  margin-top: -5px;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s;
}
.n-ico img { width: 24px; height: 24px; display: block; }
.news li:hover .n-ico { transform: translateY(-2px) rotate(-8deg) scale(1.1); box-shadow: 0 10px 18px -8px var(--glow); }
@media (prefers-reduced-motion: reduce) {
  .n-ico { transition: none; }
  .news li:hover .n-ico { transform: none; }
}
.news time { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.venue-inline { font-weight: 600; color: var(--ink); white-space: nowrap; }

/* ---------- publications ---------- */
.legend { font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.sub-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 24px 0 6px;
}

.pub {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 22px;
  padding: 16px 0;
}
.pub + .pub { border-top: 1px solid var(--line); }
.pub.compact { grid-template-columns: 1fr; padding: 12px 0; }

.thumb {
  position: relative;
  height: 112px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.thumb.placeholder { background: var(--bg-soft); }
.thumb.placeholder span { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: .3px; }

.pub h4 { font-size: 15.5px; font-weight: 600; color: var(--ink); line-height: 1.45; margin-bottom: 3px; }
.authors { font-size: 14px; color: var(--text); }
.me { font-weight: 700; color: var(--ink); }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 7px 0 4px; }
.venue {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  padding: 1px 8px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
}
.venue.ghost,
.venue.pending { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); font-weight: 500; }
.tag { font-size: 12px; color: var(--muted); padding: 1px 2px; }
.tag + .tag::before { content: "·"; margin-right: 7px; }

.links { font-size: 14px; display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.soon { font-size: 13px; color: var(--muted); font-style: italic; }

/* ---------- publication details fold ---------- */
.pub-more { margin-top: 6px; }
.pub-more summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  user-select: none;
}
.pub-more summary::-webkit-details-marker { display: none; }
.pub-more summary::before {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .2s;
}
.pub-more[open] summary::before { transform: rotate(45deg); }
.pub-more summary:hover { color: var(--accent); }
.more-body {
  margin-top: 10px;
  padding-left: 14px;
  border-left: 2px solid var(--line);
}
.more-ctx { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.more-body ul { padding-left: 18px; font-size: 14px; }
.more-body li { margin-top: 4px; }

.tl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.tl-head h3 { font-size: 16px; font-weight: 600; color: var(--ink); line-height: 1.45; }
.role { font-size: 14px; color: var(--muted); }
.date { flex-shrink: 0; font-size: 13.5px; color: var(--muted); padding-top: 2px; white-space: nowrap; }

/* ---------- projects ---------- */
.proj-media {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
  margin: 12px 0 14px;
}
.proj-photo { grid-row: span 2; overflow: hidden; border-radius: 8px; }
.proj-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.proj-clip {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}
.proj-clip video { width: 100%; height: 100%; object-fit: cover; display: block; }
.proj-clip span {
  position: absolute;
  left: 8px; bottom: 8px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}
.proj-clip:hover { text-decoration: none; }
.proj-desc { font-size: 14.5px; }
.proj-arch { margin-top: 18px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.proj-arch img { width: 100%; display: block; }

/* ---------- cards ---------- */
.card-title { font-weight: 600; color: var(--ink); font-size: 14.5px; margin: 4px 0 2px; }
.bullets { padding: 0 0 0 18px; font-size: 14.5px; }
.bullets li { margin-top: 4px; }

.edu-line { font-size: 14px; margin-top: 4px; }
.k {
  display: inline-block;
  min-width: 108px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

/* ---------- footer ---------- */
.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 24px 0 44px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; gap: 28px; padding-top: 28px; }
  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 132px 1fr;
    column-gap: 22px;
    align-items: start;
  }
  .avatar { width: 132px; grid-row: span 5; margin-bottom: 0; }
  .logos { grid-column: 1 / -1; max-width: 300px; border-top: 0; padding-top: 4px; }
  .name { font-size: 24px; margin-bottom: 6px; }
  .affil { margin-bottom: 6px; }
  .tagline { border: 0; padding: 4px 0 8px; }
  .side-links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 14px; }
  .side-links li + li { margin-top: 0; }

  .nav-toggle { display: block; }
  .nav-links {
    position: absolute;
    top: var(--nav-h); left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    height: auto;
    padding: 10px 20px 18px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
  }
  .nav-links.open { opacity: 1; transform: none; pointer-events: auto; }
  .nav-links a { height: auto; padding: 8px 12px; border-left: 2px solid transparent; }
  .nav-links a.active::after { display: none; }
  .nav-links a.active { border-left-color: var(--accent); }
  .nav-links .nav-cv { margin: 6px 0 0; align-self: flex-start; border-left: 1px solid var(--line); }
}

@media (max-width: 600px) {
  .container { padding: 0 18px; }
  .sidebar { grid-template-columns: 1fr; }
  .avatar { grid-row: auto; margin-bottom: 14px; }
  .pub { grid-template-columns: 1fr; gap: 12px; }
  .thumb { height: auto; aspect-ratio: 2 / 1; }
  .proj-media { grid-template-columns: 1fr 1fr; }
  .proj-photo { grid-column: 1 / -1; grid-row: auto; aspect-ratio: 1000 / 936; }
  .tl-head { flex-direction: column; gap: 2px; }
  .news li { grid-template-columns: 34px 1fr; column-gap: 12px; row-gap: 0; }
  .news .n-ico { grid-row: span 2; }
}
