/* 像素风界面 */
@font-face {
  font-family: 'Fusion Pixel';
  src: url('../assets/fonts/fusion-pixel-12px-proportional-zh_hans.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #12132a;
  --panel: #1b1e3a;
  --card: #242a4a;
  --card2: #2d3459;
  --edge: #0a0b18;
  --hi: #39416d;
  --text: #f4f4f4;
  --dim: #94b0c2;
  --good: #a7f070;
  --bad: #ff7b8c;
  --warn: #ffcd75;
  --gold: #ffcd75;
  --blue: #3b5dc9;
  --sky: #41a6f6;
  --green: #38b764;
  --red: #b13e53;
  --orange: #ef7d57;
  --purple: #5d275d;
  --teal: #257179;
  --notch: polygon(0 2px, 2px 2px, 2px 0, calc(100% - 2px) 0, calc(100% - 2px) 2px, 100% 2px, 100% calc(100% - 2px), calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) 100%, 2px 100%, 2px calc(100% - 2px), 0 calc(100% - 2px));
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 12px/16px 'Fusion Pixel', 'Microsoft YaHei', 'PingFang SC', 'Noto Sans SC', sans-serif;
  -webkit-font-smoothing: none;
  font-smooth: never;
  user-select: none;
}
b { font-weight: normal; color: #fff; }
p { margin: 4px 0; }
h3 { margin: 0 0 6px; font-size: 12px; font-weight: normal; color: var(--warn); display: flex; align-items: center; gap: 2px; }
h3.sec { margin: 10px 0 6px; }
details summary { cursor: pointer; color: var(--warn); outline: none; }
input {
  font: inherit; color: var(--text); background: var(--edge); border: 2px solid var(--hi); padding: 2px 6px; outline: none; user-select: text; min-width: 0;
}
input:focus { border-color: var(--sky); }

.ico { width: 16px; height: 16px; image-rendering: pixelated; vertical-align: -3px; margin-right: 3px; flex: 0 0 auto; }
.portrait { width: 48px; height: 48px; image-rendering: pixelated; flex: 0 0 auto; display: block; background: var(--edge); }
.portrait.big { width: 64px; height: 64px; }
.portrait.tiny { width: 32px; height: 32px; }
.icon-port { display: flex; align-items: center; justify-content: center; background: var(--card2); }
.icon-port img { width: 32px; height: 32px; image-rendering: pixelated; }

.dim { color: var(--dim); }
.small { font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.gold { color: var(--gold); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; flex: 0 0 auto; }
.row { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; }
.row.wrap { flex-wrap: wrap; }
.hint { color: var(--dim); margin: 4px 0 0; }
.num { display: inline-block; min-width: 22px; text-align: right; font-weight: normal; }

/* ---------- 按钮 ---------- */
button {
  font: inherit; line-height: 16px; color: var(--text); background: var(--blue); border: 0; padding: 3px 8px; cursor: pointer;
  clip-path: var(--notch);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.35), inset 2px 2px 0 rgba(255, 255, 255, 0.22);
}
button:hover:not(:disabled) { filter: brightness(1.15); }
button:active:not(:disabled) { box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.35); transform: translateY(1px); }
button:disabled { background: #383d5c; color: #7a83a6; cursor: not-allowed; box-shadow: none; }
button.primary { background: var(--green); }
button.primary:disabled { background: #383d5c; color: #7a83a6; }
button.danger { background: var(--red); }
button.on { background: var(--orange); }
button.wide { width: 100%; margin-top: 4px; }
button.big { width: 100%; padding: 8px; font-size: 24px; line-height: 24px; margin-top: 10px; }
button.mini-btn { padding: 0 6px; }

.seg { display: flex; flex-wrap: wrap; gap: 3px; }
.seg button { background: #34406e; }
.seg button.on { background: var(--orange); }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-btn { background: #34406e; }
.chip-btn.on { background: var(--orange); }
.autogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; margin: 2px 0 4px; }
.autocat { display: flex; align-items: center; gap: 6px; padding: 3px 7px; background: #2b3460; text-align: left; }
.autocat span { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.autocat b { font-weight: normal; color: var(--dim); }
.autocat.on { background: #2f6b3f; }
.autocat.on b { color: var(--good); }

/* ---------- 标签与进度条 ---------- */
.tag { display: inline-block; padding: 0 5px; background: #3a4370; color: #fff; clip-path: var(--notch); white-space: nowrap; }
.tag.gold { background: #8c6420; color: #fff4d6; }
.tag.dim { background: #2c3354; color: var(--dim); }
.tag.fund { background: #2e5a4a; }
.tag.t-good { background: #2f6b3f; }
.tag.t-bad { background: #7a2c3d; }
.tag.t-mid { background: #44507e; }
.tag.role-phd { background: var(--blue); }
.tag.role-ms { background: #2f8f55; }
.tag.role-ug { background: #b85e3f; }
.tag.role-postdoc { background: #7b3a7b; }
.tag.role-visit { background: var(--teal); }
.tag.role-jpi { background: #9c3f2e; }
.tag.t-warn { background: #7a5a1e; }
.tier { display: inline-block; min-width: 22px; text-align: center; padding: 0 3px; color: #1a1c2c; clip-path: var(--notch); flex: 0 0 auto; }
.tier.tA { background: #ffcd75; }
.tier.tB { background: #73eff7; }
.tier.tC { background: #a7f070; }
.tier.tW { background: #94b0c2; }
.tier.tP { background: #566c86; color: #fff; }

.bar { position: relative; height: 14px; background: var(--edge); flex: 1; min-width: 40px; box-shadow: inset 0 0 0 1px #000; margin: 2px 0; }
.bar > i { position: absolute; left: 1px; top: 1px; bottom: 1px; max-width: calc(100% - 2px); background: var(--sky); }
.bar.good > i { background: var(--green); }
.bar.warn > i { background: var(--orange); }
.bar.bad > i { background: var(--red); }
.bar > span { position: relative; display: block; padding: 0 5px; line-height: 14px; text-shadow: 1px 1px 0 #000; white-space: nowrap; overflow: hidden; }
.mini { display: inline-block; position: relative; width: 44px; height: 6px; background: var(--edge); box-shadow: inset 0 0 0 1px #000; vertical-align: 1px; }
.mini > i { position: absolute; left: 1px; top: 1px; bottom: 1px; max-width: calc(100% - 2px); background: var(--sky); }
.mini.good > i { background: var(--green); }
.mini.warn > i { background: var(--orange); }
.mini.bad > i { background: var(--red); }
.mini.range > i { background: #8a94c4; }

/* ---------- 布局 ---------- */
#app { display: flex; flex-direction: column; height: 100%; }
#topbar {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 6px 10px;
  background: #0d0e22; border-bottom: 2px solid #000; min-height: 40px;
}
#topbar .brand { display: flex; align-items: center; max-width: 160px; overflow: hidden; white-space: nowrap; }
#topbar .brand b { color: var(--warn); overflow: hidden; text-overflow: ellipsis; }
#topbar .date { display: flex; align-items: center; gap: 6px; }
/* 日期、学期固定宽度：日子从 9 号变成 10 号、学期变成假期时，右边的暂停 / 倍速按钮不会跟着挪 */
#topbar .date b { display: inline-block; min-width: 7em; }
#topbar .date .dim { display: inline-block; min-width: 4em; }
#topbar .speed { display: flex; gap: 3px; }
#topbar .speed button { background: #34406e; padding: 3px 6px; }
#topbar .speed button.on { background: var(--orange); }
#topbar .speed button .ico { margin: 0; }
#topbar .speed button.alert { background: var(--warn); animation: blink 0.8s steps(2) infinite; }
/* 没有待决定的事时也占着位置，免得出现 / 消失时顶栏跟着挪动 */
#topbar .speed button.alert.idle { visibility: hidden; animation: none; }
#topbar .chips { display: flex; flex-wrap: wrap; gap: 6px 12px; flex: 1; }
#topbar .chip { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#topbar .chip small { color: var(--dim); }
#topbar .chip small.good { color: var(--good); }
#topbar .chip small.bad { color: var(--bad); }
#topbar .sys { display: flex; gap: 4px; }
#topbar .sys button { background: #34406e; padding: 3px 7px; }
#topbar .sys .ico { margin: 0; }
@keyframes blink { 50% { filter: brightness(1.6); } }

#main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 410px; }
#left { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#sceneWrap { flex: 0 0 auto; display: flex; justify-content: center; align-items: center; padding: 4px; background: #08091a; }
#scene { display: block; image-rendering: pixelated; image-rendering: crisp-edges; box-shadow: 0 0 0 2px #000; }
.panel { background: var(--panel); }
.panel-title { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: #0d0e22; color: var(--warn); border-top: 2px solid #000; border-bottom: 2px solid #000; }
.log-toggle { display: none; margin-left: auto; padding: 0 8px; }
#logPanel { flex: 1 1 auto; min-height: 60px; display: flex; flex-direction: column; }
#log { flex: 1; overflow-y: auto; padding: 4px 8px; }
/* 日期一列、固定宽度，换行的文字和正文对齐 */
.log { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; padding: 1px 0; color: #d4d9e6; }
.log .d { color: #6f7aa3; white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-year { color: var(--warn); padding: 4px 0 1px; margin-bottom: 2px; border-bottom: 1px dashed #333b66; }
.log-year:first-child { padding-top: 0; }
.log.good { color: var(--good); }
.log.bad { color: var(--bad); }
.log.gold { color: var(--gold); }
.log.auto { color: #8592b8; }
#side { display: flex; flex-direction: column; min-height: 0; border-left: 2px solid #000; }
#tabs { display: flex; flex-wrap: wrap; gap: 3px; padding: 5px; background: #0d0e22; border-bottom: 2px solid #000; }
#tabs button { background: #2b3460; padding: 3px 6px; display: flex; align-items: center; }
#tabs button.on { background: var(--orange); }
#tabBody { flex: 1; overflow-y: auto; padding: 8px; overflow-anchor: none; }
/* 二级导航：贴在侧栏顶部，往下滚也看得到 */
.subnav { position: sticky; top: -8px; z-index: 3; display: flex; flex-wrap: wrap; gap: 3px; margin: -8px -8px 8px; padding: 5px 8px; background: #161936; border-bottom: 2px solid #000; }
.subnav button { background: #262d55; padding: 2px 8px; box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.35); color: #c9d3e6; }
.subnav button.on { background: #3d4a8a; color: #fff; box-shadow: inset 0 -2px 0 var(--orange); }
/* 鼠标指着的东西不乱跑：内容往上缩、已经滚到顶时临时垫高的空白 */
.apad { display: block; }
select {
  font: inherit; color: var(--text); background: var(--edge); border: 2px solid var(--hi); padding: 1px 4px; outline: none; min-width: 0; max-width: 100%; cursor: pointer;
}
select:focus { border-color: var(--sky); }
/* 论文筛选 */
.pfilter { padding: 6px 8px; }
.pf-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.pf-row > label { flex: 0 0 auto; width: 2.6em; color: var(--dim); }
.pf-row .seg { flex: 1; min-width: 0; }
.pf-sel { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.pf-sel select { flex: 1 1 30%; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); padding: 8px; margin: 0 0 8px; clip-path: var(--notch); box-shadow: inset 0 0 0 2px #313a66; }
.card .sub { color: var(--dim); margin: 8px 0 4px; border-bottom: 1px dashed #3d4677; }
.kvline { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.kvline > span:first-child:not(.grow) { flex: 1; color: var(--dim); }
.kvline .ico { margin-right: 0; }
.toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.toolbar > span { flex: 1; }
.statline { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 8px; background: var(--card); clip-path: var(--notch); margin-bottom: 6px; color: var(--dim); }
.statline b { color: #fff; }

.pi-card { display: flex; gap: 10px; align-items: flex-start; }
.pi-card .name { font-size: 12px; }
.pstats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.pstat { display: flex; align-items: center; gap: 6px; }
.pstat label { color: var(--dim); width: 28px; }
.crit { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 6px; padding: 1px 0; }
.crit .cname { display: flex; align-items: center; white-space: nowrap; overflow: hidden; }
.crit .cval { color: var(--dim); white-space: nowrap; min-width: 90px; text-align: right; }
.heat .ico { margin-right: 0; }

.mcard { display: flex; gap: 8px; background: var(--card); padding: 8px; margin-bottom: 8px; clip-path: var(--notch); box-shadow: inset 0 0 0 2px #313a66; }
.mcard.sel { box-shadow: inset 0 0 0 2px var(--orange); }
.mcard .name { color: #fff; }
.mcard .portrait { cursor: pointer; }
.stats3 { display: grid; grid-template-columns: auto auto auto auto auto auto; align-items: center; gap: 2px 4px; margin: 3px 0; color: var(--dim); width: max-content; max-width: 100%; }
.stats3 .num { color: #fff; margin-right: 6px; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 2px 8px; margin: 3px 0; color: var(--dim); }
.statgrid.wide { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.statgrid .st { display: flex; align-items: center; gap: 4px; white-space: nowrap; min-width: 0; }
.statgrid .st label { flex: 0 0 auto; }
.statgrid .mini { width: 34px; flex: 0 0 auto; }
.statgrid .num { color: #fff; }
.mini.soft > i { background: #b77fd6; }
.ovr { display: inline-block; padding: 0 5px; background: #3a4370; color: #fff; clip-path: var(--notch); white-space: nowrap; }
.ovr b { font-weight: normal; }
.ovr.gS { background: #8c6420; color: #fff4d6; }
.ovr.gA { background: #2f6b3f; }
.ovr.gB { background: #2d5d8a; }
.ovr.gC { background: #44507e; }
.ovr.gD { background: #5a3a4a; color: #e0c8d0; }
.traits { margin: 2px 0; }
.task { color: #cfd6ea; margin: 2px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.actions button { padding: 1px 7px; }

.pcard { background: var(--card); padding: 8px; margin-bottom: 8px; clip-path: var(--notch); box-shadow: inset 0 0 0 2px #313a66; }
.ptitle { color: #fff; word-break: break-word; }
.pipeline { display: flex; gap: 2px; margin: 4px 0; flex-wrap: wrap; }
.pipeline span { padding: 0 5px; background: #2b3156; color: #6f7aa3; clip-path: var(--notch); }
.pipeline span.done { background: #2f5a45; color: #b5e3c2; }
.pipeline span.cur { background: var(--orange); color: #fff; }
.paper { display: flex; gap: 8px; align-items: flex-start; padding: 5px 2px; border-bottom: 1px dashed #333b66; }
.paper.retracted .ptitle { text-decoration: line-through; color: var(--dim); }

.money-big { font-size: 24px; line-height: 28px; color: var(--good); }
.money-big.bad { color: var(--bad); }
.spark { width: 100%; height: 50px; display: block; margin-top: 6px; background: var(--edge); }
.spark polyline { fill: none; stroke: #a7f070; stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark .zero { stroke: #b13e53; stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }

/* ---------- 统计 ---------- */
.chart { position: relative; margin: 6px 0 2px; }
.chart svg { width: 100%; height: 96px; display: block; background: var(--edge); }
.chart.short svg { height: 56px; }
.chart polyline { fill: none; stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart .grid { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; vector-effect: non-scaling-stroke; }
.s1 { stroke: #a7f070; background: #a7f070; }
.s2 { stroke: #ffcd75; background: #ffcd75; }
.s3 { stroke: #41a6f6; background: #41a6f6; }
.chart .ymax { position: absolute; left: 4px; top: 2px; color: var(--dim); text-shadow: 1px 1px 0 #000; pointer-events: none; }
.xlab { display: flex; justify-content: space-between; color: var(--dim); }
.legend { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--dim); margin-top: 2px; }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; vertical-align: 0; }
.ybars { display: flex; align-items: flex-end; gap: 2px; height: 90px; padding: 4px 4px 0; background: var(--edge); margin-top: 4px; }
.ycol { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.ycol:hover { background: rgba(255, 255, 255, 0.05); }
.ystack { display: flex; flex-direction: column; }
.ystack i { display: block; min-height: 1px; }
.tA { background: var(--gold); }
.tB { background: var(--sky); }
.tC { background: #566c86; }
.ylabels { display: flex; gap: 2px; padding: 0 4px; color: var(--dim); }
.ylabels span { flex: 1; min-width: 0; text-align: center; white-space: nowrap; overflow: visible; font-size: 11px; }
.vstat { display: grid; grid-template-columns: minmax(0, 1fr) 46px minmax(96px, 42%); align-items: center; gap: 6px; padding: 1px 0; }
.vstat .vname { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.vstat .vn { text-align: right; white-space: nowrap; }
.grant-row { margin: 4px 0 8px; }
.shop-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed #333b66; }
.stepper { display: flex; align-items: center; gap: 6px; }
.fac-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fac { background: var(--card2); padding: 6px; clip-path: var(--notch); display: flex; flex-direction: column; gap: 2px; }
.fac.owned { box-shadow: inset 0 0 0 2px #2f6b3f; }
.fac button { margin-top: auto; }
.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.ach { display: flex; align-items: center; padding: 3px 4px; background: #222744; color: #5f688f; clip-path: var(--notch); }
.ach.got { background: #3d3a2a; color: var(--gold); }

/* ---------- 折叠区块 ---------- */
.fold { margin: 2px 0; }
.fold.card { padding: 0; }
.fold-head {
  width: 100%; display: flex; align-items: center; gap: 6px; text-align: left;
  background: transparent; box-shadow: none; padding: 4px 6px; color: var(--text);
}
.fold.card > .fold-head { padding: 8px; color: var(--warn); }
.fold-head:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); filter: none; }
.fold-head .caret { color: var(--dim); width: 10px; flex: 0 0 auto; }
.fold-head .grow { color: var(--text); }
.fold-body { padding: 0 8px 6px 22px; }
.fold.card > .fold-body { padding: 0 8px 8px; }
.fold.line { border-bottom: 1px dashed #333b66; }

/* ---------- 小组 ---------- */
.tag.grp { background: #262c50; color: var(--gc); box-shadow: inset 0 0 0 1px var(--gc); }
.gdot { display: inline-block; width: 8px; height: 8px; margin-left: 4px; background: var(--gc); vertical-align: 0; }
.gcard { box-shadow: inset 0 0 0 2px #313a66, inset 4px 0 0 var(--gc); padding-left: 12px; }
.gcard .gname { color: var(--gc); }
.mchip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 2px 1px 1px; background: #303868; clip-path: var(--notch); cursor: pointer; }
.mchip:hover { background: #3b4580; }
.mchip .portrait.mini { width: 16px; height: 16px; }
.mchip button.x { padding: 0 4px; background: transparent; box-shadow: none; color: var(--dim); }
.mchip button.x:hover { color: var(--bad); }

/* ---------- 算力水管 ---------- */
.pipes { display: flex; flex-direction: column; gap: 3px; margin: 4px 0 2px; }
.pipe-row { display: flex; align-items: center; gap: 6px; }
.pipe-row .pname { flex: 0 0 40%; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pipe-row .pname .gdot { margin: 0 4px 0 0; }
.pipe-row > b { flex: 0 0 32px; text-align: right; }
.pipe { position: relative; flex: 1; min-width: 60px; height: 12px; background: #151a2e; box-shadow: inset 0 0 0 1px #000, inset 0 2px 0 #2c3456, inset 0 -2px 0 #0d1020; }
.pipe .water { position: absolute; left: 1px; top: 3px; bottom: 3px; max-width: calc(100% - 2px); background: repeating-linear-gradient(90deg, #41a6f6 0 6px, #73eff7 6px 9px); background-size: 18px 100%; animation: pipeflow 1s linear infinite; }
.pipe .water.warn { background-image: repeating-linear-gradient(90deg, #3b5dc9 0 6px, #41a6f6 6px 9px); }
.pipe .water.bad { background-image: repeating-linear-gradient(90deg, #29366f 0 6px, #3b5dc9 6px 9px); }
.pipe .mark { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--gold); opacity: 0.7; }
@keyframes pipeflow { from { background-position: 0 0; } to { background-position: 18px 0; } }
@media (prefers-reduced-motion: reduce) { .pipe .water { animation: none; } }
.kvline.item { padding: 1px 0; }
.kvline.alum { border-bottom: 1px dashed #333b66; }
.mdetail .kvline > span:first-child { white-space: nowrap; }
.authors { color: var(--dim); }
.authors .gold { color: var(--gold); }

/* ---------- 成员档案 ---------- */
.motto { color: #b8c3e6; margin: 2px 0; }
.mdetail { margin-top: 6px; padding: 6px 8px; background: #1d2240; clip-path: var(--notch); }
.mdetail .sub { color: var(--warn); margin: 6px 0 2px; border-bottom: 1px dashed #3d4677; }
.story { display: flex; gap: 6px; align-items: baseline; padding: 1px 0; }
.story .dim { flex: 0 0 auto; }
.growline { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 0 10px; font-weight: normal; }

/* ---------- 经费明细 ---------- */
.stack { display: flex; height: 12px; margin-top: 8px; background: var(--edge); box-shadow: inset 0 0 0 1px #000; overflow: hidden; }
.stack i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 4px; color: var(--dim); }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; vertical-align: 0; }
.lrow { display: grid; grid-template-columns: 116px 1fr auto 34px; align-items: center; gap: 6px; padding: 2px 0; }
.lname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #cfd6ea; }
.lbar { height: 8px; background: var(--edge); box-shadow: inset 0 0 0 1px #000; position: relative; }
.lbar i { position: absolute; left: 1px; top: 1px; bottom: 1px; max-width: calc(100% - 2px); }
.lpct { text-align: right; }

/* ---------- 弹窗收起 ---------- */
.mhead .mmin { margin-left: auto; padding: 1px 8px; background: rgba(0, 0, 0, 0.25); box-shadow: none; }
.pending-bar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); pointer-events: auto;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; width: min(560px, 94vw);
  background: #0d0e22; clip-path: var(--notch); box-shadow: inset 0 0 0 2px var(--warn); animation: blink 1.6s steps(2) infinite;
}
.pending-bar .ico { margin: 0; }

/* ---------- 弹窗 ---------- */
#modalLayer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.modal-back { position: absolute; inset: 0; background: rgba(8, 9, 24, 0.72); display: flex; align-items: center; justify-content: center; pointer-events: auto; padding: 10px; }
.modal {
  width: min(560px, 96vw); max-height: 92vh; overflow-y: auto; background: var(--panel); clip-path: var(--notch);
  box-shadow: inset 0 0 0 2px #4a5490; padding: 0 12px 12px; animation: pop 0.15s steps(3);
}
.modal.wide { width: min(940px, 97vw); }
@keyframes pop { from { transform: scale(0.92); } to { transform: scale(1); } }
.mhead { display: flex; align-items: center; gap: 4px; margin: 0 -12px 10px; padding: 6px 12px; background: var(--blue); color: #fff; position: sticky; top: 0; z-index: 2; }
.modal.tone-gold .mhead { background: #b0781e; }
.modal.tone-bad .mhead { background: var(--red); }
.modal.tone-good .mhead { background: #2f8f55; }
.mbody { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.mtext { flex: 1; color: #e2e7f3; }
.mtext b { color: var(--warn); }
.mnote { margin-top: 8px; color: #7d88b3; font-size: 12px; }
.choices { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.choices.row { flex-direction: row; flex-wrap: wrap; }
.choices.row .choice { flex: 1; min-width: 180px; }
.choice { text-align: left; padding: 6px 10px; display: flex; flex-direction: column; background: #2f3a6e; }
.choice b { color: #fff; }
.choice small { color: #b8c3e6; font-size: 12px; }
.choice.def { background: #3b5dc9; box-shadow: inset 0 0 0 2px var(--warn); }
.choice.danger { background: var(--red); }
.choice:disabled small { color: var(--bad); }
.mfoot { position: sticky; bottom: -12px; margin: 10px -12px -12px; padding: 8px 12px; background: #0d0e22; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mfoot span { flex: 1; color: var(--dim); }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.ccard { background: var(--card); padding: 8px; clip-path: var(--notch); box-shadow: inset 0 0 0 2px #313a66; }
.ccard.sel { box-shadow: inset 0 0 0 2px var(--good); background: #24392f; }
.sortbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0 6px; }
.sortbar .chip-btn { padding: 1px 6px; }
.mbriefs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px; margin: 6px 0 2px; }
.mbrief { background: var(--card2); padding: 6px 8px; clip-path: var(--notch); box-shadow: inset 0 0 0 1px #3d4878; }
.mbrief .row { flex-wrap: wrap; }
.offer-card { background: var(--card); padding: 8px; margin: 6px 0; clip-path: var(--notch); box-shadow: inset 0 0 0 2px #4a5490; }
.offer-card .row { flex-wrap: wrap; }
.grant-pick { background: var(--card); padding: 8px; margin-bottom: 6px; clip-path: var(--notch); }
.grant-pick.off { opacity: 0.6; }
.venue-row.off { opacity: 0.55; }
.grant-pick .seg { margin-top: 4px; }
.venue-list { display: flex; flex-direction: column; gap: 2px; margin: 6px 0; }
.venue-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; background: var(--card); }
.venue-sec { display: flex; align-items: center; gap: 6px; padding: 8px 4px 2px; color: var(--warn); border-bottom: 1px dashed #3d4677; }
.venue-sec:first-child { padding-top: 0; }
.summary { display: flex; gap: 16px; align-items: center; margin: 4px 0 8px; }
/* 年度总结里「这一年的成长」；潜力的星星 */
.growlist { margin: 6px 0 4px; padding: 4px 8px; background: var(--card); clip-path: var(--notch); }
.growlist .kvline { gap: 10px; }
.stars { color: var(--gold); letter-spacing: -1px; }
.grade { width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; font-size: 48px; line-height: 48px; clip-path: var(--notch); flex: 0 0 auto; }
.grade.gS { background: #b0781e; color: #fff4d6; }
.grade.gA { background: #2f8f55; }
.grade.gB { background: var(--blue); }
.grade.gC { background: #566c86; }
.grade.g新 { background: var(--teal); font-size: 36px; }
.crit-table { margin-bottom: 8px; }
.help p { margin: 6px 0; color: #dde3f0; }
.help b { color: var(--warn); }

/* ---------- 开始界面 ---------- */
#startScreen {
  display: none; position: fixed; inset: 0; z-index: 40; overflow-y: auto;
  background: #12132a repeating-linear-gradient(0deg, transparent 0 15px, rgba(255, 255, 255, 0.025) 15px 16px), #12132a;
}
.start-inner { max-width: 780px; margin: 0 auto; padding: 24px 12px 40px; }
.logo { text-align: center; margin: 10px 0 18px; }
.logo .t1 { font-size: 48px; line-height: 52px; color: var(--warn); text-shadow: 4px 4px 0 var(--red), 8px 8px 0 #000; }
.logo .t2 { font-size: 24px; line-height: 30px; color: var(--sky); margin-top: 14px; letter-spacing: 2px; }
.logo .t3 { color: var(--dim); margin-top: 6px; }
.form .frow { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.form .frow > label { width: 110px; color: var(--dim); flex: 0 0 auto; }
.form .frow input { width: 220px; }
.form .hint { margin: 0 0 6px 120px; }
.continue .row { flex-wrap: nowrap; }

/* ---------- 提示 ---------- */
#toasts { position: fixed; bottom: 12px; left: 12px; z-index: 60; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: #0d0e22; padding: 6px 10px; clip-path: var(--notch); box-shadow: inset 0 0 0 2px #4a5490; max-width: 320px; transition: opacity 0.4s, transform 0.4s; }
.toast.good { box-shadow: inset 0 0 0 2px var(--green); }
.toast.bad { box-shadow: inset 0 0 0 2px var(--red); }
.toast.gold { box-shadow: inset 0 0 0 2px var(--gold); color: var(--gold); }
.toast.out { opacity: 0; transform: translateX(-20px); }
#tooltip {
  display: none; position: fixed; z-index: 100; pointer-events: none; max-width: 300px; padding: 5px 8px;
  background: #0d0e22; box-shadow: inset 0 0 0 2px #4a5490; color: #e8ecf6; white-space: normal;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0d0e22; }
::-webkit-scrollbar-thumb { background: #3f4a80; border: 2px solid #0d0e22; }
::-webkit-scrollbar-thumb:hover { background: #5563a3; }

/* ---------- 迷你模式 ---------- */
body.compact #side, body.compact #logPanel { display: none; }
body.compact #main { grid-template-columns: 1fr; }
body.compact #sceneWrap { flex: 1; }
body.compact #topbar { gap: 4px 8px; padding: 4px 6px; }
body.compact #topbar .brand, body.compact #topbar .chip:nth-child(n+4) { display: none; }

/* ---------- 窄屏 ---------- */
/* 顶栏一行放不下时：每样东西放在固定的格子里（12 列 × 3 行），日期、经费等数字变长变短时不再换行挪位 */
@media (max-width: 1100px) {
  #topbar { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px 6px; padding: 4px 8px; }
  #topbar .chips { display: contents; }
  #topbar > *, #topbar .chip { min-width: 0; overflow: hidden; white-space: nowrap; }
  #topbar .brand { grid-area: 1 / 1 / 2 / 5; max-width: none; }
  #topbar .date { grid-area: 1 / 5 / 2 / 11; }
  #topbar .sys { grid-area: 1 / 11 / 2 / 13; justify-self: end; }
  #topbar .speed { grid-area: 2 / 1 / 3 / 8; gap: 2px; }
  #topbar .speed button { padding: 3px 4px; }
  #topbar .c-funds, #topbar .c-mood { grid-area: 2 / 8 / 3 / 13; }
  #topbar .c-energy, #topbar .c-trust { grid-area: 3 / 1 / 4 / 4; }
  #topbar .c-rep { grid-area: 3 / 4 / 4 / 6; }
  #topbar .c-papers { grid-area: 3 / 6 / 4 / 9; }
  #topbar .c-cites { grid-area: 3 / 9 / 4 / 13; }
  #topbar .c-mypapers { grid-area: 3 / 4 / 4 / 10; }
  #topbar .c-mycites { grid-area: 3 / 10 / 4 / 13; }
}
@media (max-width: 900px) {
  #main { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  #left { min-height: auto; }
  #topbar .sys [data-act="compact"] { display: none; }
  /* 手机上：实验室动态放在画面下面，平时只露出最新几条，可以展开 */
  #logPanel { flex: 0 0 auto; min-height: 0; }
  #log { max-height: 100px; }
  #logPanel.open #log { max-height: 38vh; }
  .log-toggle { display: inline-block; }
  #side { border-left: 0; border-top: 2px solid #000; }
  .form .hint { margin-left: 0; }
  .crit { grid-template-columns: 100px 1fr auto; }
}

/* ---------- 博士阶段 ---------- */
.pcard.mine { box-shadow: inset 0 0 0 2px var(--gold); }
