:root {
  --bg: #fafaf9;
  --panel: #ffffff;
  --text: #1c1917;
  --muted: #6b6560;
  --line: #e7e5e4;
  --accent: #b45309;
  --accent-soft: #fff4e5;
  --tag: #f3f1ee;
  --faculty: #24497a;
  --faculty-bg: #e9eff7;
  --postdoc: #7a5410;
  --postdoc-bg: #f8f0de;
  --industry: #8f3628;
  --industry-bg: #f9ebe8;
  --radius: 8px;
  --serif: "Source Serif 4", "Source Serif Pro", Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171412; --panel: #1f1b18; --text: #f5f2ef; --muted: #a8a099; --line: #3a332e;
    --accent: #f59e0b; --accent-soft: #3a2a12; --tag: #2a2521;
    --faculty: #a9c3e8; --faculty-bg: #1b2738; --postdoc: #e2bd72; --postdoc-bg: #33280f;
    --industry: #eba293; --industry-bg: #3a1e19;
  }
}
:root[data-theme="dark"] {
    --bg: #171412; --panel: #1f1b18; --text: #f5f2ef; --muted: #a8a099; --line: #3a332e;
    --accent: #f59e0b; --accent-soft: #3a2a12; --tag: #2a2521;
    --faculty: #a9c3e8; --faculty-bg: #1b2738; --postdoc: #e2bd72; --postdoc-bg: #33280f;
    --industry: #eba293; --industry-bg: #3a1e19;
  }
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--panel); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* header */
.topbar { border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar .wrap { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 22px; padding-bottom: 0; }
.brand h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
.brand h1 span { color: var(--accent); }
.brand-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.pages { display: flex; gap: 6px; }
.pages a { font-size: 13px; font-weight: 600; color: var(--muted); padding: 3px 12px; border: 1px solid var(--line); border-radius: 999px; }
.pages a:hover { color: var(--text); text-decoration: none; border-color: var(--muted); }
.pages a.active { color: var(--accent); border-color: var(--accent); }
.tagline { margin: 4px 0 14px; color: var(--muted); font-size: 14px; }
.cycles { display: flex; gap: 4px; }
.cycles button { background: none; border: none; border-bottom: 3px solid transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.cycles button:hover { color: var(--text); }
.cycles button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- directory: summary band (same language as the stats report) ---- */
.kpis-band { display: grid; grid-template-columns: repeat(4, 1fr); margin: 24px 0 20px; padding: 12px 0 14px;
  border-top: 2px solid var(--text); border-bottom: 1px solid var(--line); }
.kpi { padding: 0 20px; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: none; padding-left: 0; }
.kpi .n { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.15; font-variant-numeric: lining-nums tabular-nums; }
.kpi .l { color: var(--text); font-size: 13.5px; margin-top: 3px; }
.kpi .l span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.cycle-note { margin: -8px 0 18px; color: var(--muted); font-size: 12.5px; }

/* ---- controls ---- */
.controls { margin: 0 0 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row + .row { margin-top: 10px; }
input[type=search], select { font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--text); }
input[type=search]:focus, select:focus { outline: 2px solid color-mix(in oklab, var(--accent) 35%, transparent); outline-offset: 0; border-color: var(--accent); }
input[type=search] { flex: 1 1 280px; min-width: 200px; }
select { max-width: 260px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; cursor: pointer; }
.btn-ghost { font: inherit; font-size: 13.5px; background: none; border: none; padding: 6px 4px; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.btn-ghost:hover { color: var(--text); }
.chips { gap: 4px 6px; }
.chip { font: inherit; font-size: 12.5px; padding: 2px 9px; border-radius: 3px; border: 1px solid var(--line); background: none; color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--muted); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--panel); }
.chip .c { color: var(--muted); font-size: 11.5px; margin-left: 5px; font-variant-numeric: tabular-nums; }
.chip.active .c { color: inherit; opacity: .75; }

.result-count { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; }

.filter-prompt { margin: 28px 0 48px; padding: 28px 0; border-top: 1.5px solid var(--text); border-bottom: 1px solid var(--line); text-align: center; }
.filter-prompt h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 20px; font-weight: 600; }
.filter-prompt p { margin: 0 auto; max-width: 36em; color: var(--muted); font-size: 14px; line-height: 1.7; }

/* ---- the directory table ---- */
.table-wrap { overflow-x: auto; margin-bottom: 36px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; vertical-align: top; }
thead th { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; color: var(--muted); background: var(--panel);
  border-bottom: 1.5px solid var(--text); position: sticky; top: 0; z-index: 1; padding-top: 10px; padding-bottom: 8px; }
table.grouped .col-school, table.grouped td.school { display: none; }
.col-name { width: 19%; }
.col-school { width: 12%; }
.col-jmp { width: 37%; }
.col-fields { width: 14%; }
.col-place { width: 18%; }

tr.group th { padding: 26px 10px 8px; border-bottom: 1px solid var(--line); font-weight: 400; background: none; position: static; letter-spacing: 0; color: var(--text); }
tr.group th .rank { display: inline-block; min-width: 36px; font-family: var(--serif); color: var(--muted); font-size: 14px; }
tr.group th .sn { font-family: var(--serif); font-size: 18px; font-weight: 600; }
tr.group th .zh { color: var(--muted); font-size: 13.5px; margin-left: 8px; }
tr.group th .n { float: right; color: var(--muted); font-size: 12px; margin-top: 5px; font-variant-numeric: tabular-nums; }
tr.group th .note { color: var(--muted); font-size: 12.5px; font-style: italic; margin-left: 12px; }
tr.group.empty th { padding-top: 12px; padding-bottom: 6px; }
tr.group.empty th .sn { font-size: 15px; font-weight: 500; color: var(--muted); }
tr.group.empty th .rank { font-size: 13px; }

tr.cand { cursor: pointer; }
tr.cand td { border-bottom: 1px solid color-mix(in oklab, var(--line) 70%, var(--panel)); }
tr.cand:hover td { background: color-mix(in oklab, var(--tag) 70%, var(--panel)); }
tr.cand.open td { background: var(--tag); border-bottom: none; }
td.name .nm { font-weight: 600; font-size: 15px; }
td.name .zh { color: var(--muted); margin-left: 5px; font-size: 14px; }
td.name .meta { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; font-variant-numeric: tabular-nums; }
td.name .site { color: var(--accent); }
td.school { font-size: 14px; }
td.school .rank { color: var(--muted); font-size: 12px; margin-right: 4px; }
td.jmp .jt { font-family: var(--serif); font-size: 15.5px; line-height: 1.45; color: var(--text); }
td.fields { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
td.fields span + span::before { content: " · "; color: color-mix(in oklab, var(--muted) 60%, var(--panel)); }
td.fields .raw { font-style: italic; }
.none { color: color-mix(in oklab, var(--muted) 70%, var(--panel)); }

/* placement: colored dot + label, then the destination */
.pl { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.pl i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pl.Faculty { color: var(--faculty); }
.pl.Non-tenure-track { color: var(--faculty); }
.pl.Non-tenure-track i { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }
.pl.Postdoc { color: var(--postdoc); }
.pl.Industry { color: var(--industry); }
.pl.Deferred { color: var(--muted); }
.pl.Deferred i { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }
td.place .txt { display: block; font-size: 13.5px; margin-top: 2px; line-height: 1.45; }

/* expanded row */
tr.detail td { background: var(--tag); padding: 4px 10px 18px; border-bottom: 1px solid var(--line); }
.detail-inner { display: grid; grid-template-columns: 2fr 1fr; gap: 28px; font-size: 14px; line-height: 1.65; }
.detail-inner h4 { margin: 0 0 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.detail-inner p { margin: 0 0 8px; }
.detail-inner ul { margin: 0; padding-left: 18px; }
.detail-inner .src { color: var(--muted); font-size: 12px; }
/* research output: label column + serif titles, like the JMP column and the stats report */
.research { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 12px; }
.research h4 { margin-bottom: 8px; }
.r-group { display: grid; grid-template-columns: 170px 1fr; gap: 16px; padding: 10px 0; }
.r-group + .r-group { border-top: 1px dashed color-mix(in oklab, var(--line) 80%, transparent); }
.r-label { display: flex; flex-wrap: wrap; align-items: baseline; align-self: start; align-content: flex-start; padding-top: 2px; gap: 2px 7px; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.r-label i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; align-self: center; }
.r-label span { flex-basis: 100%; padding-left: 14px; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.pub .r-label, .rc.pub i { color: var(--faculty); }
.rr .r-label, .rc.rr i { color: var(--postdoc); }
.wp .r-label, .rc.wp i { color: var(--muted); }
.rc.wp i { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }
.wp .r-label i { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }
.papers { list-style: none; margin: 0; padding: 0 !important; }
.papers li { margin: 0 0 9px; line-height: 1.45; }
.papers li:last-child { margin-bottom: 0; }
.papers .pt { font-family: var(--serif); font-size: 15px; color: var(--text); }
.papers .pt a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--accent) 45%, transparent); text-underline-offset: 3px; }
.papers .pt a:hover { color: var(--accent); }
.papers .pm { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.papers .pm em { color: var(--text); }
.papers .pn { font-style: italic; }
.jmp-tag { display: inline-block; margin-left: 7px; padding: 0 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; line-height: 16px;
  color: var(--accent); border: 1px solid currentColor; border-radius: 3px; vertical-align: 2px; }
td.name .rcs { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
td.name .rc { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; }
td.name .rc i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.footer { color: var(--muted); font-size: 13px; padding-bottom: 40px; border-top: 1px solid var(--line); padding-top: 14px; }
.footer .muted { opacity: .8; }

/* narrow screens: rows become stacked entries */
@media (max-width: 760px) {
  .topbar .wrap { align-items: flex-start; }
  .cycles { width: 100%; overflow-x: auto; }
  .kpis-band { grid-template-columns: 1fr 1fr; row-gap: 12px; }
  .kpi:nth-child(3) { border-left: none; padding-left: 0; }
  .kpi .n { font-size: 24px; }
  select { max-width: 100%; }
  thead { display: none; }
  table, tbody, tr, td, th { display: block; width: 100%; }
  tr.cand { padding: 12px 0 10px; border-bottom: 1px solid var(--line); }
  tr.cand td { border: none; padding: 2px 0; }
  td.name .meta { display: inline; margin-left: 6px; }
  td.jmp .jt { font-size: 15px; }
  tr.group th { padding: 20px 0 6px; }
  tr.group th .n { float: none; margin-left: 8px; }
  tr.detail td { padding: 6px 8px 14px; }
  .detail-inner { grid-template-columns: 1fr; gap: 10px; }
  .r-group { grid-template-columns: 1fr; gap: 6px; }
  .r-label span { flex-basis: auto; padding-left: 0; }
}

/* light / dark / auto switch (theme.js) */
.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.theme-switch button { font: inherit; font-size: 12px; border: none; background: none; color: var(--muted); padding: 2px 10px; border-radius: 999px; cursor: pointer; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.active { background: var(--tag); color: var(--text); font-weight: 600; }

/* ---- English site (index.html): views beyond the candidate table ---- */
.brand h1 a.home { color: inherit; text-decoration: none; }
.pages a.cn { border-style: dashed; }
.cycles[hidden] { display: none; }
.crumb { margin: 22px 0 0; color: var(--muted); font-size: 13px; }
.view-h { margin: 28px 0 4px; font-family: var(--serif); font-size: 24px; font-weight: 600; }
.intro { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }
td.name a.nm { color: var(--text); }
td.name a.nm:hover { color: var(--accent); text-decoration: none; }

/* candidate profile */
.profile { margin: 10px 0 40px; padding-top: 16px; border-top: 2px solid var(--text); }
.profile h2 { margin: 0; font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.2; }
.profile .sub { margin: 6px 0 18px; color: var(--muted); font-size: 14px; }
.profile .sub .rank { font-family: var(--serif); }
.facts { margin: 0 0 18px; border-top: 1px solid var(--line); }
.facts > div { display: grid; grid-template-columns: 170px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.facts dt { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; color: var(--muted); padding-top: 3px; }
.facts dd { margin: 0; font-size: 14px; }
.facts .jt { font-family: var(--serif); font-size: 17px; line-height: 1.45; }
.facts .place .txt { display: block; font-size: 14px; margin-top: 2px; }
.profile .research { border-top: none; padding-top: 0; }
.profile > .src { color: var(--muted); font-size: 12.5px; margin-top: 18px; }

/* institutions table */
table.inst td, table.inst th { padding: 8px 10px; }
table.inst thead th { white-space: nowrap; }
table.inst td { border-bottom: 1px solid color-mix(in oklab, var(--line) 70%, var(--panel)); font-size: 14px; }
table.inst .num { text-align: right; font-variant-numeric: tabular-nums; }
table.inst td.rank { color: var(--muted); font-family: var(--serif); }
table.inst td a { color: var(--text); }
table.inst tr.clk { cursor: pointer; }
table.inst tr.clk:hover td { background: color-mix(in oklab, var(--tag) 70%, var(--panel)); }

/* field grid */
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 28px; margin-bottom: 40px; border-top: 1.5px solid var(--text); }
.fcell { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.fcell:hover { text-decoration: none; }
.fcell:hover .fn { color: var(--accent); }
.fcell .fn { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.fcell .c { font-family: var(--serif); font-size: 17px; font-variant-numeric: tabular-nums; }
.fcell .bar { grid-column: 1 / -1; height: 4px; background: var(--tag); border-radius: 2px; overflow: hidden; }
.fcell .bar i { display: block; height: 100%; background: var(--accent); opacity: .75; }
.fcell .fs { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }

/* about */
.about { max-width: 46em; margin-bottom: 40px; font-size: 15px; line-height: 1.7; }
.about h3 { margin: 24px 0 4px; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.about p { margin: 0 0 10px; }
.about code { font-size: 13px; background: var(--tag); padding: 1px 5px; border-radius: 3px; }

@media (max-width: 760px) {
  .facts > div { grid-template-columns: 1fr; gap: 4px; }
  table.inst thead { display: table-header-group; }
  table.inst, table.inst tbody, table.inst tr, table.inst td, table.inst th { display: revert; width: auto; }
}
td.name .meta.ug { margin-top: 1px; }
.edu { list-style: none; margin: 0; padding: 0; }
.edu li { display: grid; grid-template-columns: 44px 1fr; gap: 8px; margin: 0 0 3px; }
.edu .yr { color: var(--muted); font-variant-numeric: tabular-nums; }
.edu b { font-weight: 600; }

/* discipline switcher (one directory per field) above the brand */
.dbs { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 2px 18px; margin: -10px 0 4px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.dbs:empty { display: none; }
.dbs a { color: var(--muted); font-weight: 600; padding: 2px 0; border-bottom: 2px solid transparent; }
.dbs a:hover { color: var(--text); text-decoration: none; }
.dbs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.dbs .lbl { color: var(--muted); font-weight: 400; }
.brand h1 b { font-weight: inherit; }
