:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1a1d21;
  --ink-2: #5b6470;
  --ink-3: #8b95a1;
  --line: #e6e9ee;
  --brand: #0e7490;
  --brand-2: #0891b2;
  --ok: #0f7a52;
  --ok-bg: #e7f6ef;
  --warn: #b4530a;
  --warn-bg: #fdf2e2;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body.pad { padding-bottom: env(safe-area-inset-bottom); }

a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 16px; font-weight: 600; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 6px; }

.wrap { max-width: 720px; margin: 0 auto; padding: 14px 14px 40px; }
.wrap.wide { max-width: 1180px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 13px; border-radius: 9px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  outline: none;
}
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(8, 145, 178, .12); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: #eef1f5;
  color: var(--ink-2);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.brand { background: #e0f2f7; color: var(--brand); }

.muted { color: var(--ink-3); font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(24, 28, 33, .94);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all .22s ease;
  z-index: 100;
  max-width: 84vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 26, .45);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .18s ease;
}
.sheet {
  width: 100%;
  max-width: 720px;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 86dvh;
  overflow: auto;
  animation: up .22s cubic-bezier(.2, .9, .3, 1);
}
.sheet h3 { margin: 0 0 12px; font-size: 16px; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }

/* 上传列表 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.thumb {
  position: relative;
  aspect-ratio: 4 / 3;   /* 晶体盒子基本都是横拍 */
  border-radius: 10px;
  overflow: hidden;
  background: #eef1f5;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge {
  position: absolute;
  left: 4px; bottom: 4px; right: 4px;
  font-size: 11px;
  line-height: 1.3;
  padding: 3px 5px;
  border-radius: 6px;
  background: rgba(20, 24, 30, .72);
  color: #fff;
  text-align: center;
  backdrop-filter: blur(4px);
}
.thumb .badge.ok { background: rgba(15, 122, 82, .88); }
.thumb .badge.bad { background: rgba(180, 35, 24, .9); }
.thumb .badge.run { background: rgba(14, 116, 144, .9); }
.thumb .n {
  position: absolute; top: 4px; left: 4px;
  background: rgba(20, 24, 30, .7); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 999px;
}

.shutter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 0 12px;
}
.shutter button {
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 6px 18px rgba(14, 116, 144, .35);
}
.shutter button:active { transform: scale(.95); }

.empty { text-align: center; color: var(--ink-3); padding: 30px 10px; font-size: 14px; }

/* 复核页 */
.stage {
  position: relative;
  background: #10141a;
  border-radius: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.stage .wrapimg {
  position: absolute; left: 0; top: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.stage img { display: block; max-width: none; pointer-events: none; }
/* 缩略图占位：先出模糊小图，清晰图到了再盖上去，避免空白等待 */
.stage img.ph { position: absolute; left: 0; top: 0; filter: blur(2px); opacity: .9; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay rect { fill: rgba(8, 145, 178, .10); stroke: #22d3ee; stroke-width: 2; }
.overlay rect.done { fill: rgba(16, 185, 129, .14); stroke: #34d399; }
.overlay rect.flag { fill: rgba(245, 158, 11, .16); stroke: #fbbf24; }
.overlay rect.cur { stroke: #fff; stroke-width: 3; fill: rgba(255, 255, 255, .10); }
.overlay text { font-size: 13px; font-weight: 600; fill: #06232b; }
.overlay .tag { fill: #22d3ee; }
.overlay .tag.done { fill: #34d399; }
.overlay .tag.flag { fill: #fbbf24; }
.overlay .tag.cur { fill: #fff; }

.reviewbar {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  z-index: 20;
}

.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

.kv { display: grid; grid-template-columns: 76px 1fr; gap: 8px 10px; align-items: center; }
.kv .k { color: var(--ink-3); font-size: 13px; }
.kv .v { font-weight: 600; font-size: 15px; word-break: break-all; }
.kv .v input {
  width: 100%; border: 1px dashed var(--line); border-radius: 8px;
  padding: 6px 8px; background: #fbfcfd; font-weight: 600;
}
.kv .v input:focus { border-style: solid; border-color: var(--brand-2); outline: none; background: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 12px; padding: 3px 8px; border-radius: 999px;
  background: #f1f4f7; color: var(--ink-2);
}
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

.list-items { max-height: 42vh; overflow: auto; }
.li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px;
  border: 1px solid transparent;
}
.li:active { background: #f7f9fb; }
.li.cur { background: #eef7fa; border-color: #bfe6ef; }
.li .idx {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px; background: #eef1f5; font-size: 12px; font-weight: 700;
}
.li.done .idx { background: var(--ok-bg); color: var(--ok); }
.li.flag .idx { background: var(--warn-bg); color: var(--warn); }
.li .t { flex: 1; min-width: 0; }
.li .t b { font-weight: 600; }
.li .t div { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 900px) {
  .review-grid { display: grid; grid-template-columns: 1fr 400px; gap: 0; height: calc(100vh - 52px); }
  .review-grid .stage { height: 100%; }
  .review-side { border-left: 1px solid var(--line); background: #fff; overflow: auto; }
}
