:root {
  --bg: #0b0d10;
  --panel: rgba(16, 19, 24, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f2f4f7;
  --muted: #a3acb9;
  --accent: #3ddc97;
  --accent-ink: #052416;
  --warn: #ffb020;
  --danger: #ff5a5f;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

.screen { min-height: 100%; }

/* ---------- 开始页 / 结束页 ---------- */
#setup, #done {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(32px + env(safe-area-inset-bottom));
}

h1 { font-size: 28px; margin: 0 0 6px; letter-spacing: 0.02em; }
.lead { color: var(--muted); margin: 0 0 22px; }

label { display: block; font-size: 14px; color: var(--muted); margin: 16px 0 6px; }
label.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-size: 14px; }
label.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }

select, input[type="text"] {
  width: 100%;
  padding: 13px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #161a21;
  color: var(--text);
  font-size: 16px;
}

.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.hint.list { padding-left: 18px; margin-top: 22px; }
.hint.list li { margin: 4px 0; }

.notice {
  border: 1px solid var(--warn);
  background: rgba(255, 176, 32, 0.12);
  color: #ffd98a;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 14px;
}
.notice.error { border-color: var(--danger); background: rgba(255, 90, 95, 0.12); color: #ffb3b5; }

button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  min-height: 48px;
  cursor: pointer;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.danger { color: #ffb3b5; border-color: rgba(255, 90, 95, 0.5); }
button.on { background: rgba(255, 176, 32, 0.25); border-color: var(--warn); }
button.big { display: block; width: 100%; margin-top: 22px; font-size: 18px; min-height: 56px; }

#summary { width: 100%; border-collapse: collapse; margin: 8px 0; }
#summary td { padding: 9px 4px; border-bottom: 1px solid var(--line); }
#summary td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 进行页 ---------- */
#live { position: fixed; inset: 0; overflow: hidden; background: #000; }

#cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }

.veil {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  background: rgba(8, 10, 13, 0.86);
  color: var(--muted);
  font-size: 18px;
  backdrop-filter: blur(14px);
}
.veil small { font-size: 13px; margin-top: 6px; }
#noCam { background: #0b0d10; }

#top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(10px + env(safe-area-inset-top)) 14px 22px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
}
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pill.ok { color: var(--accent); border-color: rgba(61, 220, 151, 0.5); }
.pill.bad { color: #ffb3b5; border-color: rgba(255, 90, 95, 0.6); }
.pill:empty { display: none; }

#progress { height: 5px; border-radius: 3px; background: rgba(0, 0, 0, 0.45); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18); margin-top: 10px; overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
#stepCount { display: inline-block; font-size: 13px; color: var(--text); margin-top: 7px; padding: 2px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.55); }

#alert {
  position: absolute; left: 14px; right: 14px; top: calc(96px + env(safe-area-inset-top));
  background: rgba(255, 90, 95, 0.94); color: #fff;
  border-radius: var(--radius); padding: 12px 14px; font-weight: 700; font-size: 17px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
#alert.warning { background: rgba(255, 176, 32, 0.96); color: #2b1c00; }

#bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 26px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 62%, rgba(0, 0, 0, 0));
}

#caption {
  margin: 0 0 8px; padding: 6px 10px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 15px; color: #eef2f6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
#caption:empty { display: none; }
#caption.user { color: var(--muted); }

#card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; backdrop-filter: blur(10px);
}
#card h2 { font-size: 19px; margin: 0 0 4px; }
#card p { margin: 0; }
#stepText { font-size: 16px; }
#stepCheck { margin-top: 6px !important; }
#card.done { border-color: rgba(61, 220, 151, 0.6); }

.btns { display: grid; gap: 8px; margin-top: 8px; }
.btns.main { grid-template-columns: 1fr 1fr 1fr 1.4fr; }
.btns.main button { min-height: 58px; font-size: 17px; }
.btns.sub { grid-auto-flow: column; grid-auto-columns: 1fr; }
.btns.sub button { min-height: 40px; padding: 6px; font-size: 13px; color: var(--muted); }
.btns.sub button.danger { color: #ffb3b5; }

#typeRow { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; }
#typeRow input { padding: 9px 10px; font-size: 14px; background: rgba(22, 26, 33, 0.8); }
#typeRow button { min-height: 40px; padding: 6px 14px; font-size: 14px; }

#stats { margin: 6px 2px 0; font-size: 11px; font-variant-numeric: tabular-nums; }

@media (orientation: landscape) and (max-height: 520px) {
  #bottom { left: auto; width: 46%; top: 0; padding-top: calc(64px + env(safe-area-inset-top)); background: linear-gradient(to left, rgba(0, 0, 0, 0.88) 70%, rgba(0, 0, 0, 0)); overflow-y: auto; }
  #typeRow, #stats { display: none; }
}

/* ---------- 旁观屏 ---------- */
body.board { overflow: auto; }
.board-wrap { max-width: 1400px; margin: 0 auto; padding: 16px 20px 40px; }
.board-head { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: baseline; margin-bottom: 14px; }
.board-head h1 { font-size: 22px; margin: 0; }
.board-grid { display: grid; grid-template-columns: minmax(280px, 1.2fr) minmax(260px, 1fr) minmax(300px, 1.2fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .board-grid { grid-template-columns: 1fr; } }
.panel { background: #12151b; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; }
#frame { width: 100%; border-radius: 10px; background: #000; display: block; min-height: 180px; }
#refImg { width: 100%; border-radius: 10px; background: #fff; display: block; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; padding: 8px 10px; border-radius: 9px; display: flex; gap: 10px; align-items: baseline; color: var(--muted); }
.steps li::before { content: counter(s); font-variant-numeric: tabular-nums; width: 1.4em; text-align: right; flex: none; }
.steps li.active { background: rgba(61, 220, 151, 0.14); color: var(--text); font-weight: 600; }
.steps li.done { color: #7fbfa2; }
.steps li.done::before { content: "✓"; }
.steps li .badge { margin-left: auto; font-size: 12px; color: #ffb3b5; font-weight: 400; white-space: nowrap; }
.now { font-size: 17px; }
.now h2 { margin: 0 0 6px; font-size: 22px; }
.now p { margin: 4px 0; }
table.wiring { width: 100%; border-collapse: collapse; font-size: 14px; }
table.wiring th, table.wiring td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.wiring th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.wiring tr.hot td { background: rgba(61, 220, 151, 0.16); color: #fff; }
.log { max-height: 300px; overflow-y: auto; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.log .u { color: var(--muted); }
.log .a { color: var(--text); }
.log .m { color: #ffb3b5; }
.marks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.marks button { min-height: 44px; font-size: 14px; }
.marks button span { display: block; font-size: 12px; color: var(--muted); }
.rating { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; margin-top: 12px; font-size: 14px; }
.rating select { padding: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.join { display: grid; grid-template-columns: 1fr auto; gap: 8px; max-width: 360px; }
