@import url("brand.css");

/* =============================================================================
 * PBdesign — global/design-system.css
 * -----------------------------------------------------------------------------
 * FROZEN CONTRACT. Sections use these component classes and must not redefine
 * them. To add a component, append it here and document it in
 * docs/DESIGN-SYSTEM.md.
 *
 * The token VALUES do not live here any more: global/brand.css owns them. The
 * block below maps the brand layer into the names the site has always used
 * (--bg, --accent, …), so every component rule in this file is unchanged and
 * the rendered result is identical.
 *
 * The @import is first on purpose: it guarantees brand.css is defined before
 * any rule here uses it, without making each page add a second <link>.
 *
 * Deliberately minimal: no animation, no transition, no external font.
 * It must work offline and render identically in all three regions.
 * ========================================================================== */

/* --- 1. Tokens (values: global/brand.css) -------------------------------- */
:root {
  --bg:            var(--brand-bg);
  --surface:       var(--brand-surface);
  --surface-alt:   var(--brand-surface-alt);
  --border:        var(--brand-border);
  --border-strong: var(--brand-border-strong);

  --text:          var(--brand-ink);
  --text-muted:    var(--brand-ink-muted);
  --text-faint:    var(--brand-ink-faint);

  --accent:        var(--brand-accent);
  --accent-dark:   var(--brand-accent-dark);
  --accent-soft:   var(--brand-accent-soft);

  --ok:            var(--brand-ok);
  --ok-soft:       var(--brand-ok-soft);
  --warn:          var(--brand-warn);
  --warn-soft:     var(--brand-warn-soft);
  --danger:        var(--brand-danger);
  --danger-soft:   var(--brand-danger-soft);

  --radius:        var(--brand-radius);
  --radius-sm:     var(--brand-radius-sm);
  --gap:           var(--brand-gap);
  --gap-sm:        var(--brand-gap-sm);
  --gap-lg:        var(--brand-gap-lg);

  --max-width:     var(--brand-max-width);
  --line:          var(--brand-line);

  --font:          var(--brand-font);
  --font-mono:     var(--brand-font-mono);
}

/* --- 2. Reset ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: var(--line);
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--gap-sm); font-weight: 650; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }

p { margin: 0 0 var(--gap-sm); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { margin: 0 0 var(--gap-sm); padding-left: 1.25rem; }
li { margin-bottom: 4px; }

code, .mono { font-family: var(--font-mono); font-size: 0.86em; }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--gap-lg) 0; }

/* No animation anywhere, including focus. */
:focus-visible { outline: var(--brand-focus); outline-offset: 2px; }

/* --- 3. Layout ---------------------------------------------------------- */
.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--gap); }

.page { padding: var(--gap-lg) 0; }

.section { margin-bottom: var(--gap-lg); }

/* ---------- 可折叠板块 / foldable sections --------------------------------
   标题本身就是开关（global/utils.js 的 foldSections 把 <h2> 里包了一个
   button）。收起时只藏内容，标题留着 —— 不然页面会看起来是空的，
   也没地方点回来。

   默认是**收起**的：一页先呈现一份目录，想看哪块点哪块（见 CONTRACT §6）。
   箭头：▸ 收起、▾ 展开。 */

.fold-btn {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}
.fold-btn:hover .fold-label { text-decoration: underline; text-underline-offset: 3px; }
.fold-btn:focus-visible { outline: 2px solid var(--accent, #4A6FA5); outline-offset: 3px; border-radius: 3px; }

/* 箭头：展开是 ▾，收起是 ▸。用伪元素是因为它纯粹是装饰，
   没必要进 DOM 让读屏软件念出来。 */
.fold-arrow::before { content: '▾'; font-size: 0.8em; opacity: 0.55; }
.section.folded .fold-arrow::before { content: '▸'; }

/* 收起 = 藏掉标题以外的所有直接子元素 */
.section.folded > *:not(h2) { display: none; }

/* 打印时全部展开：纸上没法点，收起的内容会直接消失。 */
@media print {
  .section.folded > *:not(h2) { display: revert; }
  .fold-arrow { display: none; }
}

.stack > * + * { margin-top: var(--gap); }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: center;
}

.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* --- 4. Nav ------------------------------------------------------------- */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gap);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap);
  min-height: 52px;
}

.nav-brand { font-weight: 700; color: var(--text); font-size: 0.98rem; }
.nav-brand:hover { text-decoration: none; }

.nav-links { display: flex; flex-wrap: wrap; gap: 2px; margin-left: auto; }

.nav-links a {
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  border-bottom: 2px solid transparent;
}

.nav-links a:hover { color: var(--text); background: var(--surface-alt); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* 导航栏的下拉菜单 / nav dropdown (drawn by renderNav in global/utils.js)
 *
 * 【怎么开】鼠标停在父项上、键盘 Tab 到父项上（:focus-within），
 *   或者触摸屏点一下（JS 加 .open，见 bindNavDropdowns）。
 *
 * 【为什么父项要包一层 .nav-item】
 *   子菜单和父项之间如果直接相邻，鼠标往下走的那一刻会经过"两边都不属于"的
 *   空隙，菜单立刻收起来、点不中。包一层之后那块空隙属于父元素，
 *   鼠标全程在 .nav-drop 里面，:hover 不会断。
 *
 * 【为什么用 visibility 而不是 display:none】
 *   display:none 的元素没法做过渡，而且它一跳出来就会顶掉布局。
 *   绝对定位 + visibility 让它浮在上面，展开是纯视觉的事。
 */
.nav-item { position: relative; }

.nav-drop-top { display: inline-flex; align-items: center; gap: 4px; }
.nav-caret { font-size: 0.7em; line-height: 1; opacity: 0.65; }

.nav-sub {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 40;
  min-width: 190px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
}

.nav-drop:hover .nav-sub,
.nav-drop:focus-within .nav-sub,
.nav-drop.open .nav-sub {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

/* 子项排成一列，各自占满整行 —— 不然它们会继承 .nav-links a 的 inline 排版 */
.nav-sub a {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border-bottom: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}
.nav-sub a:hover { color: var(--text); background: var(--surface-alt); text-decoration: none; }
.nav-sub a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* 窄屏：导航会换行，绝对定位的下拉会飘到屏幕外面 —— 改成"贴着父项往下推"，
   并且让它占满宽度。手机上本来就没有 hover，靠点按展开（.open）。 */
@media (max-width: 640px) {
  .nav-sub {
    position: static;
    min-width: 0;
    width: 100%;
    box-shadow: none;
    border-radius: var(--radius-sm);
  }
  .nav-drop { display: flex; flex-direction: column; width: 100%; }
  .nav-drop .nav-sub { display: none; }
  /* ⚠️ :hover 也要列进来。窄窗口 + 鼠标是完全正常的组合（浏览器窗口拖窄而已），
     而这一段的 display:none 会盖掉上面那条 :hover 规则 —— 只写 .open 的话，
     把窗口拖窄之后下拉就点不开了，还没有任何报错。 */
  .nav-drop:hover .nav-sub,
  .nav-drop:focus-within .nav-sub,
  .nav-drop.open .nav-sub { display: block; visibility: visible; opacity: 1; transform: none; }
}

/* 语言开关 / the language switch (drawn by renderNav in global/utils.js).
 *
 * 长得像 .nav-links 里的一项，但它是 <button>：一个动作，不是一个去处。
 * 上面写的是"点了会变成什么"—— 中文界面写 EN，英文界面写 中。
 * 尺寸跟着 .nav-links a 走（同样的字号、内边距、圆角），所以它看着像导航的一部分。
 *
 * Looks like a nav link but is a <button>: an action, not a place. Its label says
 * what you get if you click, and it borrows the nav link's shape so it reads as
 * part of the bar. */
.nav-lang {
  font: inherit;
  font-size: 0.92rem;
  line-height: 1;
  padding: 6px 10px;
  /* 导航项之间的缝隙是 2px，这里给一点，免得和最后一项贴在一起 */
  margin-left: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-muted);
  cursor: pointer;
  /* ⚠️ 窄屏：导航换行时按钮不能被压扁（'中' 会被压成一条线），也不能顶出容器 */
  flex: 0 0 auto;
}
.nav-lang:hover { border-color: var(--border-strong); color: var(--text); }
.nav-lang:focus-visible { outline: 2px solid var(--accent, #4A6FA5); outline-offset: 2px; }

/* 登录入口 / the sign-in entry — only drawn on public pages (home).
   它比语言开关更"重"：填色，因为它是首页上唯一要做的事。 */
.nav-login {
  font: inherit; font-size: 0.92rem; line-height: 1;
  padding: 6px 12px; margin-left: 8px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-weight: 600;
  white-space: nowrap;
}
.nav-login:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; text-decoration: none; }
.nav-login:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 账号区 / account area — 已登录时是头像，点开是账号菜单。
   菜单的条目和 /board 顶栏那个头像菜单一致（见 global/utils.js）。 */
.nav-account { display: inline-flex; align-items: center; margin-left: 8px; }

.nav-avatar {
  width: 34px; height: 34px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 50%; cursor: pointer;
}
.nav-avatar:hover { border-color: var(--accent); background: var(--surface-alt); }
.nav-avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.nav-account-menu {
  position: fixed; z-index: 60; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px;
  box-shadow: 0 8px 28px rgba(20, 25, 35, .14);
}
.nav-account-head { padding: 10px 12px 11px; border-bottom: 1px solid var(--surface-alt); margin-bottom: 5px; }
.nav-account-name { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.nav-account-role { font-size: 0.78rem; color: var(--text-faint); margin-top: 3px; letter-spacing: .02em; }
.nav-account-item {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 0.92rem; color: var(--text);
  border-radius: var(--radius-sm);
}
.nav-account-item:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.nav-account-danger { color: var(--danger); }

/* 窄屏：导航项换行之后，开关会掉到下一行 —— 让它靠右，而不是孤零零挂在左边。
 * On a phone the nav wraps and the switch lands on its own line: keep it on the
 * right rather than hanging at the left edge. */
@media (max-width: 560px) {
  .nav-lang { margin-left: auto; }
  /* 账号区（登录按钮或头像）靠右，语言开关跟在它后面。
     没有账号区时上面那条 .nav-lang 的 auto 照旧生效。 */
  .nav-account { margin-left: auto; }
  .nav-account + .nav-lang { margin-left: 8px; }
  .nav-account-menu { min-width: 180px; }
}

/* --- 5. Page header ----------------------------------------------------- */
.page-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--gap);
  margin-bottom: var(--gap-lg);
}

.page-head h1 { margin-bottom: 4px; }
.page-head .sub { color: var(--text-muted); margin: 0; white-space: pre-line; font-size: 0.92rem; }

/* --- 6. Card ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
}

.card-flat { background: var(--surface-alt); border-color: transparent; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--gap-sm);
}

.card h3 { margin-bottom: 4px; }
.card .meta { color: var(--text-muted); font-size: 0.86rem; }

/* --- 7. Tags and pills -------------------------------------------------- */
.tag {
  display: inline-block;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
  font-size: 0.76rem;
  line-height: 1.6;
  white-space: nowrap;
}

.tag-accent { background: var(--accent-soft); border-color: #c3d6f5; color: var(--accent-dark); }

/* 身份等级徽章（总领队 / 技术支持 / 核心成员 / 兴趣成员）。
   和"工作单元"的蓝色标签分开配色，因为两者回答的是不同的问题：
   蓝色 = 做哪个方向，这个 = 能做什么。 */
.tag-level { background: var(--brand-soft, #eef1f6); border-color: #cfd6e4; color: #3d4a63; }

/* 成果 / achievements —— 参与过哪些任务、担任什么角色 */
.member-ach { margin-top: 10px; }
.member-ach-list { margin: 6px 0 0; padding-left: 18px; }
.member-ach-list li { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 2px; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill-planning   { background: var(--surface-alt); color: var(--text-muted); }
.pill-active     { background: var(--accent-soft);  color: var(--accent-dark); }
.pill-blocked    { background: var(--danger-soft);  color: var(--danger); }
.pill-review     { background: var(--warn-soft);    color: var(--warn); }
.pill-done       { background: var(--ok-soft);      color: var(--ok); }
.pill-unassigned { background: var(--warn-soft);    color: var(--warn); }

/* --- 8. Notices --------------------------------------------------------- */
.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.notice-warn   { border-left-color: var(--warn);   background: var(--warn-soft);   color: #6b4300; }
.notice-ok     { border-left-color: var(--ok);     background: var(--ok-soft);     color: #10603a; }
.notice-info   { border-left-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }

.notice strong { color: inherit; }

/* --- 9. Stat ------------------------------------------------------------ */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px var(--gap);
}

.stat .num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--text-muted); font-size: 0.82rem; }

/* --- 10. Definition list ------------------------------------------------ */
.dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 0.9rem; }
.dl dt { color: var(--text-faint); }
.dl dd { margin: 0; }

/* --- 11. Table ---------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--surface); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--surface-alt); font-weight: 650; font-size: 0.83rem; color: var(--text-muted); }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

/* --- 12. Utilities ------------------------------------------------------ */
.muted      { color: var(--text-muted); }
.faint      { color: var(--text-faint); }
.small      { font-size: 0.86rem; }
.tiny       { font-size: 0.78rem; }
.bold       { font-weight: 650; }
.center     { text-align: center; }
.nowrap     { white-space: nowrap; }
.pre-wrap   { white-space: pre-wrap; }
.mb-0       { margin-bottom: 0; }
.mt-0       { margin-top: 0; }
.mt-1       { margin-top: var(--gap-sm); }
.mt-2       { margin-top: var(--gap); }
.mt-3       { margin-top: var(--gap-lg); }
.hidden     { display: none !important; }

/* --- 13. Member --------------------------------------------------------- */
.member-name { font-weight: 650; }
.member-nick { color: var(--text-faint); font-weight: 400; font-size: 0.88rem; }
.member-role { color: var(--accent-dark); font-size: 0.86rem; font-weight: 600; }
.member-org  { color: var(--text-muted); font-size: 0.84rem; }

/* --- 14. Channel -------------------------------------------------------- */
.channel-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm) var(--gap);
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.channel-row:last-child { border-bottom: 0; }
.channel-name { font-family: var(--font-mono); font-weight: 650; font-size: 0.92rem; min-width: 190px; }
.channel-topic { color: var(--text-muted); font-size: 0.88rem; flex: 1 1 320px; }

/* --- 15. Chat placeholder ---------------------------------------------- */
.chat-shell {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  text-align: center;
  color: var(--text-faint);
  font-size: 0.9rem;
}

/* --- 16. Controls ------------------------------------------------------- */
/* Filter buttons are <button class="tag filter-btn"> so they inherit the tag
 * look. Add .filter-btn-on to show the selected state. Sections must not
 * restyle these inline. */
.filter-btn {
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  border: 1px solid var(--border);
  /* ⚠️ 这两行是给窄屏的：按钮文字是 nowrap 的，作为 flex 子项默认会被压缩，
     压不下去就顶出容器右边（里程碑页的筛选按钮真出现过，最后一个被裁掉）。
     inline-flex 让按钮按内容撑开，flex: 0 0 auto 禁止它被压扁；
     放不下的按钮会换行 —— .tag-row 已经开了 flex-wrap。 */
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

button.filter-btn { background: var(--surface-alt); color: var(--text-muted); }
.filter-btn:hover { border-color: var(--border-strong); color: var(--text); }
.filter-btn-on { background: var(--accent); border-color: var(--accent); color: #ffffff; }
button.filter-btn-on { background: var(--accent); color: #ffffff; }

.input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
  color: var(--text);
  min-width: 220px;
}

.btn {
  font: inherit;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn:hover { border-color: var(--border-strong); }

.label { color: var(--text-faint); font-size: 0.82rem; }

.input-block { width: 100%; min-width: 0; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.row-between { justify-content: space-between; }

/* --- 17. Dialog: the quest-board claim editor --------------------------- */
.dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0;
  max-width: 620px;
  width: calc(100% - 32px);
  background: var(--surface);
  color: var(--text);
}

.dialog::backdrop { background: rgba(22, 25, 29, 0.5); }

.dialog-inner { padding: var(--gap); }

.dialog-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--gap-sm);
  margin-bottom: var(--gap);
}

.dialog-head h2 { margin: 0; font-size: 1.1rem; }

.dialog-body { max-height: 60vh; overflow-y: auto; }

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: var(--gap);
  margin-top: var(--gap);
}

.form-row { margin-bottom: var(--gap); }

.check-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface-alt);
}

.check-row {
  display: flex;
  gap: var(--gap-sm);
  align-items: baseline;
  padding: 5px 10px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.check-row:last-child { border-bottom: 0; }
.check-row:hover { background: var(--accent-soft); }
.check-row input { margin: 0; }

textarea.input { resize: vertical; font: inherit; }

/* --- 17b. Onboarding cards (training.html) ----------------------------- */
.onb-card { display: flex; gap: var(--gap); align-items: flex-start; }

.onb-num {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onb-body { flex: 1 1 auto; min-width: 0; }
.onb-body .card-head { margin-bottom: 2px; }

/* --- 17c. Material files (training.html) -------------------------------
 * 每一条材料底下的可下载文件。加这一块之前，材料只有一个 path 字段，
 * 页面上是一行路径文字；现在文件真的在 materials/ 里，路径变成按钮。
 *
 * The clickable file row. It replaced a line of path text once the materials
 * were uploaded: same information, but the reader can now act on it.
 *
 * 为什么是"行"而不是并排的按钮：一份材料可能同时有 PDF（看）和 pptx（改），
 * 每个文件要写清"这是哪一份"，横排会挤成一团。
 * Rows, not a button row: one material can carry a PDF to read and a pptx to
 * edit, and each needs its own label.
 */
.tr-files {
  list-style: none;
  margin: var(--gap-sm) 0 0;
  padding: 0;
}

.tr-file {
  display: flex;
  align-items: baseline;
  gap: var(--gap-sm);
  flex-wrap: wrap;
  margin: 0;
  padding: 5px 0;
  border-top: 1px solid var(--border);
}

.tr-file-a {
  display: flex;
  align-items: baseline;
  gap: var(--gap-sm);
  flex-wrap: wrap;
  min-width: 0;
  font-weight: 600;
}

/* 格式标签（PDF / PPTX）用等宽字，宽度随内容走 —— 不做固定宽度，
   以后加 docx、csv 不用回来改这里。 */
.tr-file-fmt {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}

.tr-file-label { min-width: 0; }

.tr-file-meta {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: var(--text-faint);
}

@media print {
  /* 纸上点不动，把链接印成地址 —— 至少还能照着敲。 */
  .tr-file-a::after { content: " (" attr(href) ")"; font-weight: 400; font-size: 0.75rem; }
}

/* --- 18. Principles highlight (index.html) ------------------------------ */
/* The one visually loud block on the site. Everything else stays quiet, so
 * this must not be reused as a generic panel. */
.principles {
  background: var(--text);
  color: #ffffff;
  border-radius: var(--radius);
  padding: var(--gap-lg) var(--gap);
}

.principles-lead {
  margin: 0 0 var(--gap);
  text-align: center;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: #c9d2df;
}

.principles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--gap);
}

.principle { text-align: center; }

.principle-zh {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.principle-en {
  font-size: 0.82rem;
  color: #a9b6c7;
  margin-top: 2px;
}

.principles-foot {
  margin: var(--gap) 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: #8d9bb0;
  letter-spacing: 0.04em;
}

/* --- 18. Footer --------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: var(--gap-lg);
  padding: var(--gap) 0;
}

.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--gap); }
.footer .notice { margin-bottom: var(--gap-sm); }

/* --- 19. 里程碑的竖向时间线 / the milestone timeline ----------------------
 *
 * 谁用：milestones.html（modules/milestones/）。
 *
 * 【为什么画成一条线，而不是一叠卡片】
 *   里程碑的意义在**顺序和间隔**：哪几个节点挨得紧、哪一段是空的。
 *   一叠卡片把间隔压平了 —— 差一天的两个和差一个月的两个，看起来一样。
 *   竖线 + 日期牌把间隔画出来了，扫一眼就知道哪里挤、哪里松。
 *
 *   The point of a milestone list is spacing: which targets sit close together
 *   and where the gaps are. A stack of cards flattens that; a rail with date
 *   badges shows it.
 *
 * 【线画在容器上，不画在每一行上】
 *   画在行上的话，行与行之间的间距（margin）会把线切断，看上去像虚线。
 *
 *   The rail is on the container: drawn per row, the gaps between rows would cut
 *   it into dashes.
 * ------------------------------------------------------------------------ */

.ms-timeline { position: relative; }

.ms-list { list-style: none; margin: 0; padding: 0; position: relative; }

.ms-row {
  display: grid;
  grid-template-columns: 74px 22px 1fr;
  gap: var(--gap-sm);
  align-items: start;
}

/* 日期牌：月和日分开写。日号大一点 —— 找日期时先看的是"几号"。 */
.ms-when { text-align: right; padding-top: 10px; }
.ms-month { font-size: 0.78rem; color: var(--text-faint); letter-spacing: 0.06em; }
.ms-day { font-size: 1.5rem; font-weight: 700; line-height: 1.05; color: var(--text); }
.ms-weekday { font-size: 0.72rem; color: var(--text-faint); margin-top: 1px; }

/* 圆点占住中间那一列，竖线从圆点中心穿过 */
.ms-dot {
  justify-self: center;
  width: 11px; height: 11px;
  margin-top: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  z-index: 1;
}
/* 竖线落在中间那一列的正中：74px 日期牌 + 半个 gap + 半列（11px）− 1px */
.ms-list::before {
  content: '';
  position: absolute;
  top: 16px; bottom: 16px;
  left: calc(74px + var(--gap-sm) / 2 + 11px - 1px);
  width: 2px;
  background: var(--border);
  z-index: 0;
}
.ms-card { margin-bottom: var(--gap); min-width: 0; }
.ms-row:last-child .ms-card { margin-bottom: 0; }

/**
 * 卡片头部：标题在左，"还有几天"在右。
 *
 * `flex-wrap: wrap` 是必须的 —— .card-head 默认 nowrap，窄屏上
 * "还有 20 天 / In 20 days" 这颗胶囊会顶出卡片右边、直接被裁掉（真出现过）。
 * 换行之后它掉到标题下面一行，仍然读得通。
 *
 * .card-head is nowrap by default; on a narrow screen the "in N days" pill was
 * pushed outside the card and clipped. Wrapping drops it to the next line.
 */
.ms-card .card-head { flex-wrap: wrap; gap: var(--gap-sm); }
.ms-card .card-head > div { min-width: 0; overflow-wrap: anywhere; }

/* "还有几天"这一颗胶囊：越近越显眼，颜色本身就是紧迫度 */
.ms-when-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-alt);
  color: var(--text-muted);
}
.ms-when-pill.today   { background: var(--danger-soft); color: var(--danger); }
.ms-when-pill.soon    { background: var(--warn-soft);   color: var(--warn); }
.ms-when-pill.recent  { background: var(--ok-soft);     color: var(--ok); }
.ms-when-pill.past,
.ms-when-pill.distant { background: var(--surface-alt); color: var(--text-muted); }

/* 四类节点各一个圆点颜色，和卡片上的标签对应 */
.ms-row.kind-deadline .ms-dot { border-color: var(--danger); }
.ms-row.kind-release  .ms-dot { border-color: var(--ok); }
.ms-row.kind-event    .ms-dot { border-color: var(--accent-dark); }

/**
 * 概览里的第四个格子放的是日期（'2026-10-11'），比一个数字长得多。
 * 等宽字体、小一号，并允许在任意位置断行 —— 否则窄屏上会顶出格子被裁掉。
 *
 * The fourth tile holds a date, not a number: monospace, one size down, and
 * allowed to break anywhere so it cannot overflow the tile.
 */
#ms-stats .stat .num { font-size: 1.15rem; font-family: var(--font-mono); overflow-wrap: anywhere; }

@media (max-width: 560px) {
  .ms-row { grid-template-columns: 52px 18px 1fr; }
  .ms-day { font-size: 1.25rem; }
  .ms-list::before { left: calc(52px + var(--gap-sm) / 2 + 9px - 1px); }
  .ms-dot { width: 9px; height: 9px; margin-top: 15px; }
}

/* --- 20. 双语 / bilingual (global/i18n.js) -------------------------------
 *
 * 【这条规则在关掉什么】
 *   模块里有一种固定写法：中文句子后面跟一个英文回声 ——
 *
 *     告知我们以下四项即可：……
 *     <span class="faint"> / Tell us four things: …</span>
 *
 *   中文那句被翻成英文之后，回声说的是同一句话，于是英文模式下面会连说两遍。
 *   运行时（global/i18n.js 的 markEchoes）会给这种 span 打上 .i18n-echo，
 *   由这一条规则在英文模式下隐藏它。
 *
 *   ⚠️ 只有"中文那句确实有译文"时才会打这个标记。词典还没覆盖到那句话时，
 *      回声保持可见 —— 藏掉它等于把英文读者唯一看得懂的那半拿走。
 *
 *   ⚠️ 中英成对的内容（里程碑标题、成员卡、首页的原则格）**不在**这条之内：
 *      那些是两行并排的设计，切语言时不藏任何一半（CONTRACT §7）。
 *
 * The modules append an English echo to some Chinese sentences. Once the Chinese
 * is translated the echo repeats it, so the runtime marks it and this rule hides
 * it in English mode — only when the sentence really was translated, so nothing
 * readable is ever hidden. Bilingual *pairs* are a different thing and stay.
 * ---------------------------------------------------------------------- */
html[lang="en"] .i18n-echo { display: none; }

/* --- 21. 项目树 / the project tree ---------------------------------------
 *
 * 谁用：projects.html（modules/quest-board/）。
 *
 * 【为什么是树，不是卡片墙】
 *   项目之间有上下位：竞赛 → 蛋白质设计 → 长江杯 / Adaptyv；研究图谱 →
 *   疾病图谱 → 肿瘤学知识 → HPV。卡片墙把层级压平了，读的人看不出谁属于谁。
 *   竖线 + 缩进画的是层级，节点里的两块画的是"推进"和"产出"。
 *
 *   A wall of cards flattens the hierarchy; the rail and indent show what belongs
 *   to what, and each project node carries its two halves: progress and output.
 *
 * 【为什么时间轴默认收起】
 *   它回答的是"这件事怎么走到今天的"，不是第一眼要看的数字。收起来之后，
 *   树的骨架仍然一眼能读完；要追踪时再展开。
 *   The timeline answers "how did this get here"; it is collapsed so the tree
 *   stays scannable, and opened when someone is tracing progress.
 * ---------------------------------------------------------------------- */

.pb-tree,
.pb-tree ul { list-style: none; margin: 0; padding: 0; }

.pb-tree { display: block; }

.pb-tree > .pb-node + .pb-node { margin-top: var(--gap); }

.pb-tree .pb-children {
  margin: .45rem 0 0 1.05rem;
  padding-left: 1.05rem;
  border-left: 1px solid var(--border-strong);
}

.pb-tree .pb-children > .pb-node { position: relative; }
.pb-tree .pb-children > .pb-node + .pb-node { margin-top: var(--gap-sm); }

/* 横向连接线：从父级的竖线连到子节点标题 */
.pb-tree .pb-children > .pb-node::before {
  content: '';
  position: absolute;
  left: -1.05rem;
  top: 1.05rem;
  width: .85rem;
  border-top: 1px solid var(--border-strong);
}

.pb-node { min-width: 0; }

.pb-node-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .45rem;
  min-width: 0;
}

.pb-node-title { font-weight: 700; overflow-wrap: anywhere; }
.pb-tree > .pb-node > .pb-node-head .pb-node-title { font-size: 1.02rem; }

.pb-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  padding: 0 .4rem;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.45;
}

/* 每个项目节点的两块：推进（左）和产出（右）。窄屏上竖着排。 */
.pb-split {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  align-items: start;
  gap: var(--gap-sm);
  margin: .5rem 0 .25rem;
}

.pb-part {
  min-width: 0;
  padding: .55rem .72rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.pb-part h4 {
  margin: 0 0 .25rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text-muted);
}

.pb-part-count {
  display: inline-block;
  margin-left: .2rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-faint);
  font-size: .7rem;
  font-weight: 700;
}

.pb-tasks { list-style: none; margin: 0; padding: 0; }

.pb-task {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .3rem 0;
  border-bottom: 1px dashed var(--border);
}

.pb-task:last-child { border-bottom: 0; }

.pb-task-title { min-width: 0; overflow-wrap: anywhere; }
.pb-task-title a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.pb-task-title a:hover { color: var(--accent-dark); border-bottom-color: var(--accent); }
.pb-task .pill { flex: 0 0 auto; }

.pb-empty { margin: .2rem 0; color: var(--text-faint); font-size: .82rem; }

.pb-outputs { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.pb-outputs a { color: var(--accent-dark); font-weight: 600; }
.pb-output-note { display: block; color: var(--text-faint); font-size: .76rem; }

/* 推进时间轴的竖排轨道 */
.pb-timeline {
  margin-top: .45rem;
  padding-top: .35rem;
  border-top: 1px dashed var(--border);
}
.pb-timeline summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: .78rem;
}
.pb-timeline summary:hover { color: var(--text); }
.pb-tl-count {
  display: inline-block;
  min-width: 1.2rem;
  padding: 0 .3rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-faint);
  font-size: .68rem;
  text-align: center;
}

.pb-tl {
  list-style: none;
  margin: .4rem 0 0;
  padding: 0 0 0 .85rem;
  border-left: 2px solid var(--border);
}

.pb-tl li {
  position: relative;
  padding: .18rem 0 .32rem .45rem;
  font-size: .78rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.pb-tl li::before {
  content: '';
  position: absolute;
  left: -1.24rem;
  top: .52rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}

.pb-tl-date {
  margin-right: .35rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: .72rem;
}

.pb-tl-act {
  display: inline-block;
  margin-right: .25rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: .7rem;
  font-weight: 600;
}

@media (max-width: 760px) {
  .pb-split { grid-template-columns: 1fr; }
  .pb-tree .pb-children { margin-left: .6rem; padding-left: .7rem; }
  .pb-tree .pb-children > .pb-node::before { left: -.7rem; width: .55rem; }
}
