@font-face {
  font-family: "Newsreader";
  src: url("/fonts/newsreader-560.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/fonts/newsreader-680.woff2") format("woff2");
  font-weight: 650;
  font-display: swap;
}
:root {
  --ink: #2b2728;
  --muted: #6a6266;
  --faint: #8a8084;
  --line: #e4dfe0;
  --paper: #f3f2f2;
  --card: #fff;
  --accent: #c24b6e;
  --accent-soft: #f8eef1;
  --pe: #6d5bd0;
  --pe-soft: #efecfb;
  --other: #c9c2c5;
  --queue: #e0a93b;
  --down: #4f86a8;
  --step: #2b2728;
  --hi: #2f7d55;
  --hi-soft: #e5f2ea;
  --mid: #b07414;
  --mid-soft: #f8ecd8;
  --lo: #9a9195;
  --lo-soft: #eeebec;
  --err: #b4352f;
  --err-soft: #fbe9e7;
  --shadow: 0 18px 48px #2b27281f;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font: 14px/1.6 "WenQuanYi Micro Hei", "PingFang SC", "Noto Sans SC", sans-serif; }
h1, h2 { font-family: "Newsreader", "Songti SC", serif; font-weight: 650; margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
pre { font: 12px/1.55 ui-monospace, "SFMono-Regular", Menlo, monospace; white-space: pre-wrap; word-break: break-all; margin: 0; }

.masthead {
  display: grid; grid-template-columns: auto minmax(0, 560px); gap: 48px; justify-content: space-between; align-items: end;
  padding: 28px 40px 22px; background: var(--card); border-bottom: 1px solid var(--line);
}
.kicker { margin: 0 0 4px; font-size: 11px; letter-spacing: .18em; color: var(--faint); }
.masthead h1 { font-size: 44px; line-height: 1; }
.lede { margin: 0; color: var(--muted); font-size: 13px; }

.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; padding: 24px 40px 60px; align-items: start; }
.side { position: sticky; top: 20px; display: grid; gap: 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.panel h2 { font-size: 20px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.meta { color: var(--faint); font-size: 12px; }
.note { margin: 10px 0 0; color: var(--faint); font-size: 12px; }

/* form */
#form { display: grid; gap: 14px; }
.drop {
  display: grid; place-items: center; min-height: 220px; border: 1.5px dashed #d4cccf; border-radius: 12px;
  background: #faf8f9; cursor: pointer; overflow: hidden; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop img { max-width: 100%; max-height: 340px; display: block; }
.drop-hint { color: var(--muted); text-align: center; }
.drop-hint small { color: var(--faint); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 3px 16px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; color: var(--muted); }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggles { display: grid; gap: 6px; }
.toggle { display: flex; gap: 8px; align-items: center; cursor: pointer; font-size: 13px; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
.advanced summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.advanced textarea { width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: vertical; font-size: 13px; }
#go {
  border: 0; border-radius: 10px; padding: 11px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; letter-spacing: .04em;
}
#go:disabled { background: #d9cfd3; cursor: not-allowed; }
.error { margin: 0; color: var(--err); font-size: 13px; }

.history h2 { margin-bottom: 8px; }
.history ol { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.history li a {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: inherit;
}
.history li a:hover { background: #f6f3f4; }
.history li a.active { background: var(--accent-soft); }
.history .h-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.history .h-sub { grid-column: 1 / -1; color: var(--faint); font-size: 11px; }

/* empty state */
.empty { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px 32px; color: var(--muted); }
.empty > p { margin: 0 0 18px; font-size: 15px; color: var(--ink); }
.flow { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 12px; }
.flow li { counter-increment: s; display: grid; grid-template-columns: 28px 120px 1fr; gap: 10px; align-items: baseline; }
.flow li::before { content: counter(s); font-family: "Newsreader", serif; font-size: 20px; color: var(--accent); }
.flow b { color: var(--ink); }

/* summary */
#result { display: grid; gap: 18px; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-family: "Newsreader", serif; font-size: 30px; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; color: var(--faint); font-weight: 500; margin-left: 2px; }
.stat .s { font-size: 11px; color: var(--faint); }
.stat.status-running .v { color: var(--accent); }
.stat.status-error .v { color: var(--err); }

/* waterfall */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.sw-step { background: var(--step); } .sw-other { background: var(--other); } .sw-pe { background: var(--pe); } .sw-gen { background: var(--accent); }
.sw-queue { background: var(--queue); } .sw-down { background: var(--down); }
.waterfall { display: grid; gap: 6px; }
.wf-row { display: grid; grid-template-columns: 200px 1fr 88px; gap: 12px; align-items: center; font-size: 12px; }
.wf-row.sub .wf-label { padding-left: 14px; color: var(--muted); }
.wf-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-track { position: relative; height: 18px; background: #f6f4f5; border-radius: 4px; }
.wf-bar { position: absolute; top: 2px; bottom: 2px; display: flex; border-radius: 3px; overflow: hidden; min-width: 2px; }
.wf-bar.step { background: var(--step); }
.wf-bar.running { background: repeating-linear-gradient(45deg, var(--accent) 0 6px, #d8738f 6px 12px); animation: slide 1s linear infinite; background-size: 17px 17px; }
.wf-bar.error { background: var(--err); }
.wf-bar.queued { background: transparent; border: 1px dashed var(--other); }
.wf-bar i { display: block; height: 100%; }
.seg-other { background: var(--other); } .seg-queue { background: var(--queue); } .seg-pe { background: var(--pe); } .seg-gen { background: var(--accent); } .seg-down { background: var(--down); }
.wf-time { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.wf-axis { display: grid; grid-template-columns: 200px 1fr 88px; gap: 12px; font-size: 11px; color: var(--faint); }
.wf-axis .ticks { position: relative; height: 14px; }
.wf-axis .ticks span { position: absolute; transform: translateX(-50%); }
@keyframes slide { to { background-position: 17px 0; } }

/* figure + table */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 18px; align-items: start; }
.stage { position: relative; line-height: 0; border-radius: 10px; overflow: hidden; background: #eee; }
.stage img { width: 100%; display: block; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.box { fill: transparent; stroke-width: 2.5; vector-effect: non-scaling-stroke; transition: fill .12s; }
.box.v-高 { stroke: var(--hi); } .box.v-中 { stroke: var(--mid); } .box.v-低, .box.v- { stroke: var(--lo); stroke-dasharray: 6 4; }
.box.skip { opacity: .65; }
.box.hot { fill: #ffffff40; stroke-width: 4; }
.tag { position: absolute; transform: translate(-1px, -100%); padding: 0 6px; font-size: 11px; line-height: 18px; color: #fff; border-radius: 4px 4px 4px 0; white-space: nowrap; pointer-events: none; }
.tag.v-高 { background: var(--hi); } .tag.v-中 { background: var(--mid); } .tag.v-低, .tag.v- { background: var(--lo); }

.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th { text-align: left; font-weight: 500; color: var(--faint); font-size: 12px; border-bottom: 1px solid var(--line); padding: 4px 6px; }
.items-table td { border-bottom: 1px solid #f0ecee; padding: 7px 6px; vertical-align: top; }
.items-table tr.hot td { background: #faf6f7; }
.items-table .cat { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); }
.items-table .why { display: block; font-size: 11px; color: var(--faint); }
.vis { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; }
.vis.v-高 { background: var(--hi-soft); color: var(--hi); } .vis.v-中 { background: var(--mid-soft); color: var(--mid); } .vis.v-低, .vis.v- { background: var(--lo-soft); color: var(--muted); }
.go { font-size: 12px; } .go.yes { color: var(--accent); } .go.no { color: var(--faint); }
.raw { margin-top: 14px; }
.raw summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.raw pre { margin-top: 8px; background: #faf8f9; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; max-height: 420px; overflow: auto; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; transition: box-shadow .15s, border-color .15s; }
.card.hot { border-color: var(--accent); box-shadow: var(--shadow); }
.card-head { display: flex; gap: 10px; align-items: baseline; padding: 12px 14px 8px; }
.card-head .idx { font-family: "Newsreader", serif; font-size: 20px; color: var(--accent); }
.card-head .nm { font-weight: 600; flex: 1; min-width: 0; }
.card-head .nm small { display: block; font-weight: 400; font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--faint); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); }
.pane { position: relative; background: #faf9f9; aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; }
.pane img { max-width: 100%; max-height: 100%; display: block; cursor: zoom-in; }
.pane .cap { position: absolute; left: 8px; top: 6px; font-size: 11px; color: var(--faint); background: #ffffffcc; padding: 0 6px; border-radius: 4px; }
.pane.out { background: #fff; }
.pane .wait { color: var(--faint); font-size: 12px; text-align: center; }
.pane .wait.err { color: var(--err); padding: 0 16px; line-height: 1.5; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.timing { display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid var(--line); }
.timing > div { padding: 8px 10px; border-right: 1px solid #f0ecee; min-width: 0; }
.timing > div:last-child { border-right: 0; }
.timing .k { font-size: 11px; color: var(--faint); white-space: nowrap; }
.timing .v { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.timing .v.queue { color: var(--queue); } .timing .v.pe { color: var(--pe); } .timing .v.gen { color: var(--accent); } .timing .v.down { color: var(--down); }
.mini { height: 5px; display: flex; }
.mini i { display: block; height: 100%; }
.card-body { padding: 10px 14px 14px; display: grid; gap: 8px; font-size: 12px; }
.card-body .reason { color: var(--muted); }
.card-body details summary { cursor: pointer; color: var(--muted); }
.card-body details pre { margin-top: 6px; background: #faf8f9; border-radius: 6px; padding: 8px 10px; max-height: 260px; overflow: auto; }
.card-body .pe-text { background: var(--pe-soft); }
.card-foot { color: var(--faint); font-size: 11px; font-family: ui-monospace, Menlo, monospace; word-break: break-all; }
.skipped-list { margin-top: 14px; color: var(--faint); font-size: 12px; }

.lightbox { position: fixed; inset: 0; background: #1d1a1bd9; display: grid; place-items: center; z-index: 10; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; background: #fff; border-radius: 6px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .side { position: static; }
  .split { grid-template-columns: 1fr; }
  .masthead { grid-template-columns: 1fr; gap: 10px; padding: 20px 16px; }
  .wf-row, .wf-axis { grid-template-columns: 120px 1fr 70px; }
  .cards { grid-template-columns: 1fr; }
}
