:root {
  /* Layout idea: a lab roster as a ruled list, each row opening one research page set in a single reading column. */
  --paper: #f5f7f6;
  --surface: #ffffff;
  --ink: #15252b;
  --muted: #5a6b70;
  --line: #d5dedb;
  --accent: #0e6a5b;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0ec;
  --gold: #8a6410;
  --gold-soft: #f6ecd2;
  --danger: #b03a2e;
  --font-display: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", "Songti SC", serif;
  --font-body: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "PingFang SC", "Microsoft YaHei", "Yu Gothic", "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10191b; --surface: #172326; --ink: #e6eeec; --muted: #9db0b1; --line: #2b3b3e;
    --accent: #5fc7b2; --accent-ink: #06231d; --accent-soft: #1b3531; --gold: #e2bd66; --gold-soft: #3a3118; --danger: #ef8a7e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #10191b; --surface: #172326; --ink: #e6eeec; --muted: #9db0b1; --line: #2b3b3e;
  --accent: #5fc7b2; --accent-ink: #06231d; --accent-soft: #1b3531; --gold: #e2bd66; --gold-soft: #3a3118; --danger: #ef8a7e;
  color-scheme: dark;
}
html[lang="zh"] { --font-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-body: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Hiragino Sans", sans-serif; }
html[lang="en"] { --font-display: "Noto Serif JP", Georgia, "Times New Roman", serif;
  --font-body: "Segoe UI", "Helvetica Neue", Arial, "Hiragino Sans", sans-serif; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-body);
  font-size: 16px; line-height: 1.8; }
a { color: var(--accent); }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; height: auto; display: block; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 1px solid var(--line); }
.bar-in { max-width: 1040px; margin: 0 auto; padding: 10px 20px; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.brand { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--ink); text-decoration: none; margin-right: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 5px 12px; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 5px 14px; font-size: 14px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 2px 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.status { font-size: 13px; color: var(--muted); }
.editnote { background: var(--gold-soft); color: var(--ink); border-bottom: 1px solid var(--line); font-size: 14px; }
.editnote div { max-width: 1040px; margin: 0 auto; padding: 8px 20px; }

main { max-width: 1040px; margin: 0 auto; padding: 36px 20px 80px; }

/* index */
.eyebrow { font-size: 13px; letter-spacing: .08em; color: var(--accent); font-weight: 600; margin: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; text-wrap: balance; line-height: 1.4; margin: 0; }
.home h1 { font-size: clamp(28px, 5vw, 42px); margin-top: 6px; }
.lead { max-width: 40em; color: var(--muted); margin: 14px 0 0; }
.group { margin-top: 44px; }
.group-head { display: flex; align-items: baseline; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.group-head h2 { font-size: 20px; }
.group-head .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.roster { list-style: none; margin: 0; padding: 0; }
.roster li { border-bottom: 1px solid var(--line); display: flex; align-items: stretch; }
.row { flex: 1; min-width: 0; display: grid; grid-template-columns: 64px 11em 1fr 20px; gap: 6px 18px; align-items: baseline;
  padding: 16px 8px; color: inherit; text-decoration: none; }
.row:hover { background: var(--surface); }
.row:hover .go { color: var(--accent); transform: translateX(3px); }
.grade { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); font-size: 15px; }
.row .who { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.row .what { color: var(--ink); font-size: 15px; line-height: 1.6; }
.go { color: var(--muted); transition: transform .15s; }
.badge { display: inline-block; font-family: var(--font-body); font-size: 12px; font-weight: 600; color: var(--gold); background: var(--gold-soft);
  border-radius: 3px; padding: 0 7px; line-height: 1.7; vertical-align: middle; white-space: nowrap; }
.who .badge { margin-left: 8px; }
.rowtools { display: flex; align-items: center; gap: 4px; padding: 0 4px; }
@media (max-width: 720px) {
  .row { grid-template-columns: 48px 1fr 20px; }
  .row .what { grid-column: 2 / 3; }
  .row .go { grid-row: 1; grid-column: 3; }
}
@media (prefers-reduced-motion: reduce) { .go { transition: none; } }

/* detail */
.back { display: inline-block; font-size: 14px; text-decoration: none; margin-bottom: 22px; }
.detail { max-width: 760px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.meta .who { font-family: var(--font-display); font-weight: 600; font-size: 20px; }
.detail h1 { font-size: clamp(23px, 3.6vw, 31px); margin-top: 10px; }
.summary { font-size: 17px; margin: 18px 0 0; padding-left: 16px; border-left: 3px solid var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 0; padding: 0; list-style: none; }
.chips li { font-size: 13px; background: var(--accent-soft); color: var(--ink); border-radius: 3px; padding: 0 9px; line-height: 1.9; }
.kwedit { font-size: 14px; margin-top: 18px; }
.sec { margin-top: 38px; }
.sec h2 { font-size: 19px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.sec p { margin: 12px 0 0; }
.sec ul { margin: 12px 0 0; padding-left: 1.3em; }
.sec li { margin-top: 5px; }
.sec li::marker { color: var(--accent); }
.raw { white-space: pre-wrap; margin-top: 12px; }

.flow { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; counter-reset: st; }
.flow > li { counter-increment: st; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 4px; padding: 12px 14px 14px; min-width: 0; }
.flow.steps > li::before { content: counter(st, decimal-leading-zero); display: block; font-size: 13px; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums; }
.flow .st { font-weight: 700; font-size: 15px; line-height: 1.5; }
.flow .sd { font-size: 14px; color: var(--muted); line-height: 1.6; margin-top: 4px; white-space: pre-wrap; }
.flowwrap { overflow-x: auto; }
.flow.screens { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.flow.screens > li { border-top: 1px solid var(--line); padding: 0; overflow: hidden; border-radius: 8px; }
.winbar { display: flex; align-items: center; gap: 5px; padding: 7px 10px; background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.winbar i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); display: block; flex: none; }
.winbar .st { margin-left: 5px; font-size: 13px; }
.screen { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 7px; font-size: 13px; line-height: 1.5; }
.screen .ln { color: var(--muted); }
.screen .opt { display: flex; gap: 7px; align-items: center; border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px; }
.screen .opt::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--muted); flex: none; }
.screen .opt.on { border-color: var(--accent); }
.screen .opt.on::before { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 2px var(--surface); }
.screen .bubble { background: var(--gold-soft); border-radius: 8px 8px 8px 2px; padding: 7px 9px; color: var(--ink); }
.screen .fake { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-radius: 5px; padding: 2px 12px; font-weight: 600; margin-top: 2px; }
.screens .sd { padding: 10px 12px 12px; margin: 0; }

figure { margin: 22px 0 0; }
figure img { border: 1px solid var(--line); border-radius: 4px; background: #fff; }
figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.linkbtn { display: inline-flex; align-items: center; gap: 8px; background: var(--accent); color: var(--accent-ink); text-decoration: none;
  border-radius: 6px; padding: 7px 16px; font-weight: 600; font-size: 15px; }
.linkbtn:hover { filter: brightness(1.08); }
.linkurl { font-size: 13px; color: var(--muted); word-break: break-all; margin-top: 4px; }

/* edit mode */
[contenteditable] { outline: 1px dashed var(--accent); outline-offset: 3px; border-radius: 2px; min-height: 1.6em; cursor: text; }
[contenteditable]:focus { outline: 2px solid var(--accent); background: var(--surface); }
[contenteditable]:empty::before { content: attr(data-ph); color: var(--muted); opacity: .7; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.sechead { display: flex; gap: 8px; align-items: flex-start; }
.sechead h2 { flex: 1; min-width: 0; }
.field { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; margin-top: 10px; font-size: 14px; }
.field label, .field .lab { color: var(--muted); font-size: 13px; }
.field .val { flex: 1; min-width: 12em; }
.editimg { border: 1px dashed var(--line); border-radius: 6px; padding: 10px; margin-top: 16px; }
.addbar { margin-top: 26px; padding-top: 14px; border-top: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 8px; }
.dangerzone { margin-top: 48px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 6px; font-size: 14px; max-width: min(92vw, 560px); z-index: 30; }
.foot { margin-top: 64px; font-size: 13px; color: var(--muted); }

/* hero figure and widgets */
.hero { margin: 26px 0 0; }
.hero .frame { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.hero .frame img { border: 0; border-radius: 4px; width: 100%; }
.hero .seg { margin-bottom: 12px; flex-wrap: wrap; }
.more { margin-top: 40px; border-top: 2px solid var(--ink); }
.more > summary { cursor: pointer; padding: 12px 0; font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.more > summary:hover { color: var(--accent); }
.more .sec:first-of-type { margin-top: 18px; }

.facew { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 20px; align-items: center; }
@media (max-width: 560px) { .facew { grid-template-columns: 1fr; } .facew svg { max-width: 200px; margin: 0 auto; } }
.facew svg { width: 100%; height: auto; display: block; }
.facew .ctl label { display: block; font-size: 14px; font-weight: 700; }
.facew input[type="range"] { width: 100%; accent-color: var(--accent); margin: 6px 0 2px; }
.scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.meters { display: grid; gap: 10px; margin-top: 16px; }
.meter { display: grid; grid-template-columns: 9.5em 1fr; gap: 10px; align-items: center; font-size: 13px; }
.meter .track { height: 10px; background: var(--accent-soft); border-radius: 5px; overflow: hidden; }
.meter .fill { height: 100%; background: var(--accent); border-radius: 5px; transition: width .2s; }
.meter .fill.gold { background: var(--gold); }
@media (prefers-reduced-motion: reduce) { .meter .fill { transition: none; } }

.clsw { display: grid; grid-template-columns: 1.15fr auto 1fr; gap: 14px; align-items: center; }
@media (max-width: 640px) { .clsw { grid-template-columns: 1fr; } .arrowcol { transform: rotate(90deg); justify-self: center; } }
.clsw .qs { display: grid; gap: 8px; align-content: start; }
.clsw .q { text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 10px 10px 10px 2px; padding: 8px 12px;
  font-size: 14px; line-height: 1.6; cursor: pointer; }
.clsw .q:hover { border-color: var(--accent); }
.clsw .q[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.clsw .res { border-left: 3px solid var(--accent); padding: 4px 0 4px 16px; align-self: start; }
.clsw .res .k { font-size: 12px; color: var(--muted); letter-spacing: .06em; }
.clsw .res .lab { font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.4; margin-top: 2px; }
.clsw .res .why { font-size: 14px; margin-top: 8px; }

.barsw .axis { display: grid; grid-template-columns: 1fr 1fr; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.barsw .axis span:last-child { text-align: right; }
.barsw .brow { display: block; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 9px 4px; cursor: pointer; }
.barsw .brow:hover, .barsw .brow[aria-pressed="true"] { background: var(--paper); }
.barsw .bl { font-size: 13.5px; line-height: 1.5; display: flex; justify-content: space-between; gap: 12px; }
.barsw .bl b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.barsw .bt { position: relative; height: 12px; margin-top: 6px; background: linear-gradient(to right, transparent calc(50% - .5px), var(--muted) calc(50% - .5px), var(--muted) calc(50% + .5px), transparent calc(50% + .5px)); }
.barsw .bf { position: absolute; top: 1px; bottom: 1px; background: var(--accent); border-radius: 2px; }
.barsw .bf.neg { background: var(--gold); }
.barsw .note { margin-top: 10px; padding: 10px 12px; background: var(--accent-soft); border-radius: 4px; font-size: 14px; }
.erow { border: 1px dashed var(--line); border-radius: 6px; padding: 8px 10px; margin-top: 10px; }

.arrowcol, .carrow { font-size: 24px; color: var(--accent); font-weight: 700; }
.chatwin { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--paper); }
.chat { padding: 12px; display: flex; flex-direction: column; gap: 4px; min-height: 150px; }
.who2 { font-size: 11px; color: var(--muted); letter-spacing: .05em; }
.who2.me { align-self: flex-end; }
.msg { max-width: 88%; padding: 7px 11px; font-size: 14px; line-height: 1.6; border-radius: 10px; margin-bottom: 6px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 2px; }
.msg.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 2px; }

.fw { border-collapse: separate; border-spacing: 0 5px; width: 100%; min-width: 520px; font-size: 14px; line-height: 1.5; }
.fw th { text-align: left; padding: 4px 10px 8px; vertical-align: bottom; width: 26%; }
.fw th:last-child { width: 48%; }
.fw .fwh { display: block; font-family: var(--font-display); font-size: 16px; }
.fw th small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.fw td { padding: 7px 10px; vertical-align: top; }
.fw td.p { background: var(--gold-soft); border-left: 3px solid var(--gold); border-radius: 3px 0 0 3px; }
.fw td.a { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.fw td.m { background: var(--paper); color: var(--muted); font-size: 13px; border-radius: 0 3px 3px 0; }
.fw td.none { color: var(--muted); text-align: center; }
.fw td b { font-variant-numeric: tabular-nums; }
.fwmix { margin-top: 8px; padding: 8px 12px; font-size: 14px; border-radius: 3px;
  background: linear-gradient(to right, var(--gold-soft), var(--accent-soft)); }

.rankq { margin: 0 0 8px; font-size: 14px; }
.rankends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.rank { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 5px; }
.rank li { display: grid; grid-template-columns: 2.2em 1.2em 1fr auto auto; gap: 6px; align-items: center; background: var(--paper); border: 1px solid var(--line);
  border-radius: 5px; padding: 5px 8px; font-size: 14px; cursor: grab; user-select: none; -webkit-user-select: none; }
.rank li.dragging { border-color: var(--accent); background: var(--accent-soft); cursor: grabbing; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.rank .no { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; text-align: right; }
.rank .grip { color: var(--muted); touch-action: none; cursor: grab; }

.compose { display: grid; grid-template-columns: 2.6fr auto 1fr; gap: 10px; align-items: center; }
@media (max-width: 700px) { .compose { grid-template-columns: 1fr; } .carrow { transform: rotate(90deg); justify-self: center; } }
.cimg img { border: 1px solid var(--line); background: #fff; }
.ctag { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .05em; margin-bottom: 4px; }
.cflow { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; counter-reset: cs; }
.cflow li { position: relative; counter-increment: cs; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 4px; padding: 8px 10px; background: var(--paper); }
.cflow li + li::before { content: "↓"; position: absolute; top: -22px; left: 50%; transform: translateX(-50%); color: var(--accent); font-weight: 700; line-height: 22px; }
.cflow .st { font-weight: 700; font-size: 14px; line-height: 1.5; }
.cflow .sd { font-size: 13px; color: var(--muted); line-height: 1.55; margin-top: 2px; }

.mbars { display: grid; gap: 8px; }
.mrow { display: grid; grid-template-columns: minmax(8em, 15em) 1fr 3em; gap: 10px; align-items: center; font-size: 13.5px; line-height: 1.4; }
.mrow b { font-variant-numeric: tabular-nums; text-align: right; }
.mt { height: 14px; background: var(--accent-soft); border-radius: 2px; }
.mf { height: 100%; background: var(--accent); border-radius: 2px; }
@media (max-width: 520px) { .mrow { grid-template-columns: 1fr 3em; } .mrow .ml { grid-column: 1 / -1; } .maxis { display: none; } }

.heat { border-collapse: separate; border-spacing: 3px; font-size: 13px; font-variant-numeric: tabular-nums; margin: 0 auto; }
.heat th { font-weight: 700; padding: 2px 8px; color: var(--muted); }
.heat td { width: 4.2em; height: 2.6em; text-align: center; border-radius: 3px; }
.heatlab { text-align: center; font-size: 12px; color: var(--muted); margin: 2px 0; }
.legend { display: flex; gap: 6px; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); margin-left: 8px; }
.legend .neg { background: var(--gold); } .legend .pos { background: var(--accent); } .legend .zero { background: var(--surface); }
.hero + .hero { margin-top: 18px; }
.sec .hero { margin-top: 14px; }

.dlgwrap { position: fixed; inset: 0; z-index: 40; background: rgba(10,20,22,.45); display: grid; place-items: center; padding: 16px; }
.dlg { background: var(--surface); color: var(--ink); border-radius: 8px; padding: 22px; width: min(100%, 380px); display: grid; gap: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dlg h2 { font-size: 18px; }
.dlg label { font-size: 13px; color: var(--muted); }
.dlg input { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }
