:root {
  --red: #d7141a;
  --red-dark: #a90e13;
  --bg: #f5f3f0;
  --card: #ffffff;
  --ink: #1d1b1a;
  --muted: #77706b;
  --line: #e6e1dc;
  --pass: #17924f;
  --pass-bg: #e6f5ec;
  --fail: #d12b1f;
  --fail-bg: #fdeae8;
  --part: #c97a00;
  --part-bg: #fff3dd;
  --wa: #1fa855;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
#app { max-width: 680px; margin: 0 auto; min-height: 100vh; padding-bottom: 96px; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

/* Top bars */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--red); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
}
.top-row { display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .sub { font-size: 12px; opacity: .85; }
.icon-btn { background: rgba(255,255,255,.16); border: 0; color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 20px; flex: none; }
.score-pill { background: #fff; color: var(--red); font-weight: 800; border-radius: 999px; padding: 6px 12px; font-size: 15px; flex: none; font-variant-numeric: tabular-nums; }
.bar { height: 5px; background: rgba(255,255,255,.3); border-radius: 3px; margin-top: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #fff; border-radius: 3px; transition: width .2s; }
.steps { display: flex; gap: 6px; overflow-x: auto; margin: 10px -14px 0; padding: 0 14px 2px; scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.step { flex: none; border: 0; background: rgba(255,255,255,.16); color: #fff; padding: 7px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; }
.step.on { background: #fff; color: var(--red); font-weight: 700; }
.step small { opacity: .8; margin-left: 4px; font-variant-numeric: tabular-nums; }

.page { padding: 14px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.h2 { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 18px 4px 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border: 0; border-radius: 12px; background: var(--red); color: #fff; font-weight: 700; font-size: 16px; padding: 12px 16px; }
.btn:active { background: var(--red-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn.wa { background: var(--wa); }
.btn.danger { background: #fff; color: var(--fail); border: 1.5px solid var(--fail-bg); }
.btn[disabled] { opacity: .45; }
.link { background: none; border: 0; color: var(--red); font-weight: 600; padding: 8px 0; font-size: 14px; }
.stack > * + * { margin-top: 10px; }

/* Fields */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
label.f em { color: var(--red); font-style: normal; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=date], textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; min-height: 48px;
}
textarea { min-height: 72px; resize: vertical; }
select { width: 100%; min-height: 48px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; font: inherit; color: inherit; }
select:focus { outline: 2px solid var(--red); outline-offset: -1px; }
input[readonly] { background: #f3f0ec; color: var(--muted); }
input:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: -1px; }

/* Home list */
.row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 8px; width: 100%; border: 0; text-align: left; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.row .grow { flex: 1; min-width: 0; }
.row b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-row { padding: 0; gap: 0; }
.row-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 14px 6px 14px 14px; background: none; border: 0; text-align: left; }
.row-del { flex: none; width: 52px; align-self: stretch; border: 0; border-left: 1px solid var(--line); background: none; font-size: 18px; border-radius: 0 var(--radius) var(--radius) 0; }
.row-del:active { background: var(--fail-bg); }
.tag { flex: none; border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tag.pass { background: var(--pass-bg); color: var(--pass); }
.tag.fail { background: var(--fail-bg); color: var(--fail); }
.tag.draft { background: #eee9e4; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }

/* Section + items */
.sec-head { display: flex; align-items: baseline; gap: 8px; margin: 4px 4px 2px; }
.sec-head h2 { font-size: 20px; flex: 1; }
.sec-head .pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.grp { display: flex; align-items: center; gap: 8px; margin: 18px 4px 8px; }
.grp h3 { font-size: 14px; font-weight: 700; flex: 1; }
.grp .red { background: var(--fail-bg); color: var(--fail); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.item { background: #fff; border-radius: var(--radius); padding: 13px; margin-bottom: 10px; border-left: 5px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.item.s-pass { border-left-color: var(--pass); }
.item.s-fail { border-left-color: var(--fail); }
.item.s-part { border-left-color: var(--part); }
.item-head { display: flex; gap: 10px; align-items: flex-start; }
.item-head .n { flex: none; width: 26px; height: 26px; border-radius: 50%; background: #f0ece8; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.item-head .t { flex: 1; min-width: 0; }
.item-head .en { font-size: 15px; font-weight: 600; }
.item-head .cn { font-size: 13px; color: var(--muted); margin-top: 3px; }
.item-head .mx { flex: none; font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.star { color: var(--red); }
.choices { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 12px; }
.choices.tier, .choices.two { grid-template-columns: 1fr 1fr; }
.c { min-height: 48px; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; font-weight: 700; padding: 6px 12px; }
.c small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.c.pass.on { background: var(--pass); border-color: var(--pass); color: #fff; }
.c.fail.on { background: var(--fail); border-color: var(--fail); color: #fff; }
.c.part.on { background: var(--part); border-color: var(--part); color: #fff; }
.c.on small { color: rgba(255,255,255,.9); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { min-width: 44px; min-height: 44px; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; font-weight: 700; }
.chip.on { background: var(--part); border-color: var(--part); color: #fff; }
.extra { margin-top: 10px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb { position: relative; width: 76px; height: 76px; border-radius: 10px; overflow: hidden; background: #eee; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 15px; line-height: 1; }
.add-photo { width: 76px; height: 76px; border-radius: 10px; border: 1.5px dashed #c9c2bb; background: #faf8f6; color: var(--muted); font-size: 12px; font-weight: 600; }
.add-photo b { display: block; font-size: 22px; font-weight: 400; }

/* Bottom nav */
.foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: rgba(245,243,240,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
.foot > div { max-width: 652px; margin: 0 auto; display: flex; gap: 10px; }
.foot .btn.ghost { flex: 0 0 34%; }

/* Review */
.total { text-align: center; padding: 20px 14px; }
.total .big { font-size: 46px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.total .big small { font-size: 20px; color: var(--muted); font-weight: 600; }
.verdict { display: inline-block; margin-top: 10px; padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 14px; }
.verdict.pass { background: var(--pass-bg); color: var(--pass); }
.verdict.fail { background: var(--fail-bg); color: var(--fail); }
.srow { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.srow:last-child { border-bottom: 0; }
.srow span { flex: 1; }
.srow b { font-variant-numeric: tabular-nums; }
.mini { flex: 0 0 64px; height: 6px; background: #eee9e4; border-radius: 3px; overflow: hidden; }
.mini i { display: block; height: 100%; background: var(--pass); }
.mini.low i { background: var(--part); }
.alert { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
.alert.red { background: var(--fail-bg); color: var(--fail); }
.alert.green { background: var(--pass-bg); color: var(--pass); }
.alert .link { padding: 0; }
.alert.amber { background: var(--part-bg); color: #8a5400; }
.ded { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ded:last-child { border-bottom: 0; }
.ded .top-l { display: flex; gap: 8px; }
.ded .top-l span { flex: 1; font-weight: 600; }
.ded .top-l b { color: var(--fail); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ded .note { color: var(--muted); margin-top: 3px; }
.sig { border: 1.5px dashed #c9c2bb; border-radius: 12px; background: #fff; position: relative; height: 170px; overflow: hidden; }
.sig canvas { width: 100%; height: 100%; touch-action: none; display: block; }
.sig .hint { position: absolute; inset: 0; display: grid; place-items: center; color: #b9b1aa; pointer-events: none; font-size: 14px; }
.sig-head { display: flex; align-items: center; margin-bottom: 6px; }
.sig-head span { flex: 1; font-size: 13px; font-weight: 600; }

/* Modal + toast */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 680px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
.sheet h2 { font-size: 18px; margin-bottom: 14px; }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); background: #222; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 40; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (min-width: 700px) {
  .modal { align-items: center; }
  .sheet { border-radius: 18px; }
}
