/* ==========================================================
   Qiyan Zhao — personal homepage
   Sticky sidebar + reading column. All colors are tokens:
   light in :root, dark in [data-theme="dark"].
   To re-theme the site, change --accent and the --tint-* values.
   ========================================================== */

:root {
  --bg: #fbfaf7;
  --fg: #1c1f1e;
  --fg-soft: #3a403e;
  --muted: #5f6764;
  --card: #ffffff;
  --accent: #0d6b62;
  --accent-fg: #ffffff;
  --accent-tint: #e3f1ee;
  --rule: rgba(28, 31, 30, 0.11);
  --rule-strong: rgba(28, 31, 30, 0.22);
  --tint-1: #e3f1ee;
  --tint-2: #f4ecdf;
  --tint-3: #e7ebf5;
  --mark: rgba(13, 107, 98, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 28px -18px rgba(0, 0, 0, 0.18);

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "PingFang SC", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e1312;
  --fg: #e7ecea;
  --fg-soft: #c9d1ce;
  --muted: #9aa6a2;
  --card: #151c1a;
  --accent: #5ccfbf;
  --accent-fg: #062320;
  --accent-tint: rgba(92, 207, 191, 0.12);
  --rule: rgba(231, 236, 234, 0.12);
  --rule-strong: rgba(231, 236, 234, 0.24);
  --tint-1: #142d29;
  --tint-2: #2a2419;
  --tint-3: #1b2234;
  --mark: rgba(92, 207, 191, 0.22);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px -18px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s, color 0.25s;
}

img { display: block; max-width: 100%; }
p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
b, strong { font-weight: 600; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-wrap: balance;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}
.link:hover { text-decoration-color: var(--accent); }

.kicker {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.rise { animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
@media (prefers-reduced-motion: reduce) {
  .rise { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------------- Shell ---------------- */

.shell {
  display: grid;
  gap: 2.5rem;
  max-width: 78rem;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 1rem;
}
@media (min-width: 768px) { .shell { padding: 0 2.5rem; } }
@media (min-width: 1024px) {
  .shell { grid-template-columns: 15rem minmax(0, 1fr); gap: 5rem; }
}

main { min-width: 0; padding: 0 0 3rem; }
@media (min-width: 1024px) { main { padding: 3.5rem 0 4rem; } }

.col { max-width: 44rem; margin: 0 auto; }
.col-wide { max-width: 62rem; margin: 0 auto; }
.stack > * + * { margin-top: 4.5rem; }

.site-footer {
  margin-top: 5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------------- Sidebar ---------------- */

.sidebar-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 2.5rem 0 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}
@media (min-width: 1024px) {
  .sidebar { position: sticky; top: 3.5rem; height: fit-content; }
  .sidebar-inner { align-items: flex-start; padding: 0; text-align: left; border-bottom: 0; }
}

.portrait {
  width: 148px;
  height: 148px;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 8px 8px 0 var(--tint-1);
  background: var(--tint-1);
}

.id h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
.id .role { margin-top: 0.35rem; font-weight: 500; font-size: 14.5px; }
.id .affil { margin-top: 0.15rem; font-size: 13.5px; line-height: 1.5; color: var(--muted); }

.side-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}
.side-nav a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 14px;
  color: var(--fg-soft);
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.side-nav a span { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.side-nav a:hover { color: var(--accent); }
.side-nav a[aria-current="page"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-tint);
}
.side-nav a[aria-current="page"] span { color: var(--accent); }
@media (min-width: 1024px) {
  .side-nav { flex-direction: column; flex-wrap: nowrap; gap: 0.1rem; width: 100%; }
  .side-nav a {
    padding: 0.35rem 0 0.35rem 0.85rem;
    border: 0;
    border-left: 2px solid var(--rule);
    border-radius: 0;
  }
  .side-nav a[aria-current="page"] { background: none; border-left-color: var(--accent); color: var(--fg); font-weight: 500; }
}

.side-links { display: flex; gap: 0.5rem; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 9px;
  color: var(--fg-soft);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}
.icon-btn:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-1px); }
.icon-btn svg { width: 16px; height: 16px; }
.theme-toggle .i-sun { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }

.email-text { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ---------------- Section heads ---------------- */

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}
.sec-head h3 {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 1.4rem;
  white-space: nowrap;
}
.sec-head .idx { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--accent); }
.sec-head::after { content: ""; flex: 1; height: 1px; background: var(--rule); align-self: center; }
.sec-head .more {
  order: 3;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.2s;
}
.sec-head .more:hover { color: var(--accent); }

/* ---------------- Home ---------------- */

.headline {
  margin-top: 0.6rem;
  font-size: 2.1rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
@media (min-width: 640px) { .headline { font-size: 2.5rem; } }
.mark {
  background: linear-gradient(transparent 62%, var(--mark) 62%);
  padding: 0 0.08em;
}

.bio { margin-top: 1.5rem; font-size: 16.5px; line-height: 1.75; color: var(--fg-soft); }
.bio > p + p { margin-top: 1.1rem; }
.bio b { color: var(--fg); }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 1.5rem; }
.chips li {
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--fg-soft);
  background: var(--card);
}

.timeline { position: relative; margin-left: 4px; padding-left: 1.5rem; border-left: 1px solid var(--rule-strong); }
.timeline li { position: relative; }
.timeline li + li { margin-top: 1.35rem; }
.timeline li::before {
  content: "";
  position: absolute;
  left: calc(-1.5rem - 5px);
  top: 0.4rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.timeline time { display: block; font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em; color: var(--accent); }
.timeline p { margin-top: 0.15rem; font-size: 15px; line-height: 1.6; color: var(--fg-soft); }
.timeline p b { color: var(--fg); }

.glance { display: grid; gap: 1rem; }
@media (min-width: 640px) { .glance { grid-template-columns: repeat(3, 1fr); } }
.g-card {
  position: relative;
  padding: 1.25rem 1.2rem 1.35rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.25s, border-color 0.25s;
}
.g-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.g-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--accent); opacity: 0.85; }
.g-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--accent);
}
.g-icon svg { width: 18px; height: 18px; }
.t1 { background: var(--tint-1); }
.t2 { background: var(--tint-2); }
.t3 { background: var(--tint-3); }
.g-card .g-verb { margin-top: 0.9rem; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.g-card h4 { margin-top: 0.15rem; font-size: 1.15rem; }
.g-card p { margin-top: 0.5rem; font-size: 13.5px; line-height: 1.6; color: var(--fg-soft); }

.pub-mini li { padding: 0.95rem 0; border-top: 1px solid var(--rule); }
.pub-mini li:last-child { border-bottom: 1px solid var(--rule); }
.pub-mini .t { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; line-height: 1.35; }
.pub-mini .a { margin-top: 0.2rem; font-size: 13px; color: var(--muted); }
.pub-mini .a b { color: var(--fg); }
.pub-mini .m { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin-top: 0.45rem; }

.plain { font-size: 15px; color: var(--fg-soft); }

/* ---------------- Shared: pills & links ---------------- */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.pill-solid { background: var(--accent); color: var(--accent-fg); }
.pill-ghost { background: none; border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent); }

.mini-links { display: inline-flex; gap: 0.4rem; }
.mini-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  font-size: 12px;
  color: var(--fg-soft);
  transition: color 0.2s, border-color 0.2s;
}
.mini-links a:hover { color: var(--accent); border-color: var(--accent); }
.mini-links svg { width: 12px; height: 12px; }

/* ---------------- Research ---------------- */

.r-hero h1 { margin-top: 0.6rem; font-size: 2.3rem; line-height: 1.08; letter-spacing: -0.02em; }
@media (min-width: 640px) { .r-hero h1 { font-size: 3rem; } }
.r-hero .tagline { margin-top: 0.9rem; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.r-hero .lead { max-width: 40rem; margin-top: 1rem; font-size: 16px; line-height: 1.75; color: var(--fg-soft); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.5rem; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn:not(.btn-primary):hover { border-color: var(--accent); color: var(--accent); }

/* pipeline diagram */
.pipeline {
  margin-top: 2.5rem;
  padding: 1.5rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background-color: var(--card);
  background-image: radial-gradient(var(--rule-strong) 1px, transparent 1px);
  background-size: 18px 18px;
}
.pl-io { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem 0.75rem; }
.pl-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.pl-io ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
.pl-io li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 12px;
  color: var(--fg-soft);
}
.pl-io li svg { width: 13px; height: 13px; color: var(--accent); }
.pl-down { display: block; width: 14px; height: 14px; margin: 0.6rem auto; color: var(--muted); }
.pl-stages { display: grid; gap: 0.5rem; }
.pl-stages > svg { justify-self: center; width: 14px; height: 14px; color: var(--muted); transform: rotate(90deg); }
@media (min-width: 640px) {
  .pl-stages { grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; }
  .pl-stages > svg { align-self: center; transform: none; }
}
.pl-stage {
  padding: 0.9rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--rule);
}
.pl-stage .pl-n { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.pl-stage b { display: block; margin-top: 0.1rem; font-family: var(--serif); font-size: 1.1rem; }
.pl-stage span:last-child { display: block; margin-top: 0.15rem; font-size: 12.5px; line-height: 1.45; color: var(--fg-soft); }

/* research rows */
.r-rows { margin-top: 3.5rem; }
.r-row { display: grid; gap: 1.75rem; padding: 2.75rem 0; border-top: 1px solid var(--rule); }
.r-row:last-child { border-bottom: 1px solid var(--rule); }
@media (min-width: 900px) { .r-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); gap: 2.75rem; } }
.r-row h2 { margin-top: 0.4rem; font-size: 1.65rem; line-height: 1.15; }
.r-row .desc { margin-top: 0.8rem; font-size: 15px; line-height: 1.75; color: var(--fg-soft); }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 1rem; }
.tags li {
  padding: 0.05rem 0.5rem;
  border-radius: 5px;
  background: var(--accent-tint);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--accent);
}
.r-figs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; align-content: start; }
@media (min-width: 900px) { .r-figs { grid-template-columns: 1fr; } }
.r-figs img, .e-card img {
  width: 100%;
  height: 9.5rem;
  object-fit: contain;
  padding: 0.4rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.r-figs figcaption { margin-top: 0.4rem; font-size: 11.5px; color: var(--muted); }

.selected { margin-top: 1.5rem; }
.selected .label { margin-bottom: 0.6rem; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.selected li { position: relative; padding-left: 1rem; font-size: 13.5px; line-height: 1.55; color: var(--fg-soft); }
.selected li + li { margin-top: 0.5rem; }
.selected li::before { content: "→"; position: absolute; left: 0; color: var(--accent); font-size: 12px; }
.selected a { text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; transition: color 0.2s, text-decoration-color 0.2s; }
.selected a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.selected .v { margin-left: 0.3rem; font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--accent); white-space: nowrap; }

/* embodied testbed */
.testbed { margin-top: 4.5rem; }
.testbed > .lead { max-width: 44rem; margin: -0.75rem 0 1.75rem; font-size: 15px; color: var(--fg-soft); }
.e-grid { display: grid; gap: 1rem; }
@media (min-width: 768px) { .e-grid { grid-template-columns: repeat(3, 1fr); } }
.e-card {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.75rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.e-card img { height: 10.5rem; border-radius: 8px; }
.e-card .body { padding: 0 0.5rem; }
.e-card .kicker { margin-top: 1rem; font-size: 10.5px; }
.e-card h3 { margin-top: 0.3rem; font-size: 1.2rem; }
.e-card .body > p:not(.kicker) { margin-top: 0.4rem; font-size: 13.5px; line-height: 1.6; color: var(--fg-soft); }
.e-card .selected { margin-top: 1rem; }
.e-card .pill { margin-top: 1rem; }

/* ---------------- Publications ---------------- */

.page-head h1 { margin-top: 0.6rem; font-size: 2.3rem; letter-spacing: -0.02em; }
.page-head p:not(.kicker) { margin-top: 0.75rem; font-size: 15px; color: var(--fg-soft); }

.filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1.5rem; }
.filters button {
  padding: 0.3rem 0.8rem;
  background: var(--card);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-size: 13px;
  color: var(--fg-soft);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.filters button:hover { color: var(--accent); border-color: var(--accent); }
.filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

.pub-list > li + li { margin-top: 1.75rem; }
.pub { display: grid; gap: 0.9rem; }
@media (min-width: 640px) { .pub { grid-template-columns: 10.5rem minmax(0, 1fr); gap: 1.4rem; } }
.pub-thumb {
  max-width: 18rem;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  padding: 0.3rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.pub-thumb img { width: 100%; height: 100%; object-fit: contain; }
.pub-title { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; line-height: 1.32; }
.pub-authors { margin-top: 0.35rem; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.pub-authors b { color: var(--fg); }
.pub-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem; margin-top: 0.55rem; }
.pub[hidden], .pub-year[hidden] { display: none; }
.footnote { font-size: 12.5px; color: var(--muted); }

/* ---------------- News page ---------------- */

.news-year { display: grid; gap: 1rem; }
@media (min-width: 768px) {
  .news-year { grid-template-columns: 6rem minmax(0, 1fr); gap: 2rem; }
  .news-year .year { position: sticky; top: 3.5rem; height: fit-content; }
}
.news-year .year { font-family: var(--serif); font-size: 2rem; font-weight: 600; color: var(--accent); line-height: 1; }
