:root {
  --bg: #f4f6fa; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --primary: #2563eb; --primary-ink: #fff;
  --ok: #15803d; --ok-bg: #ecfdf3; --warn: #b45309; --warn-bg: #fffbeb; --err: #b91c1c; --err-bg: #fef2f2; --info: #1d4ed8; --info-bg: #eff6ff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --card: #181c24; --text: #e5e7eb; --muted: #9ca3af; --line: #2a303b;
    --ok: #4ade80; --ok-bg: #12261a; --warn: #fbbf24; --warn-bg: #2a2110; --err: #f87171; --err-bg: #2c1515; --info: #93c5fd; --info-bg: #142035;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 18px; }
main { max-width: 980px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 16px; }
h2 { margin: 0 0 12px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
h3 { margin: 16px 0 6px; font-size: 15px; }
.num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
select, input[type=number] {
  font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
select { width: 100%; }
#paper-select { width: auto; flex: 1; min-width: 200px; }
input[type=number] { width: 80px; }
.btn {
  font: inherit; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 11px 16px; font-weight: 600;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: transparent; }
.btn:active { transform: scale(.98); }
.spec-info ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips span { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid #999; }
.tips { margin-top: 10px; color: var(--muted); font-size: 14px; }
.tips summary { cursor: pointer; color: var(--text); }
.privacy, .hint, .disclaimer { color: var(--muted); font-size: 13px; }
.disclaimer { text-align: center; padding: 0 8px 24px; }

.result-grid { display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: 20px; }
@media (max-width: 720px) { .result-grid { grid-template-columns: 1fr; } .preview-wrap { max-width: 280px; margin: 0 auto; width: 100%; } }
.preview { position: relative; width: 100%; box-shadow: 0 2px 12px rgba(0,0,0,.18); background: #fff; transition: opacity .2s; }
.preview.updating { opacity: .55; }
.preview canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.preview-meta { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 8px 0; cursor: pointer; }
.summary { border-radius: 12px; padding: 10px 14px; font-weight: 700; margin-bottom: 10px; }
.summary.pass { background: var(--ok-bg); color: var(--ok); }
.summary.warn { background: var(--warn-bg); color: var(--warn); }
.summary.error { background: var(--err-bg); color: var(--err); }
.report { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.report li { display: flex; gap: 10px; padding: 8px 12px; border-radius: 10px; font-size: 14px; }
.report li b { display: block; }
.report li small { display: block; color: var(--muted); font-size: 13px; }
.report .error { background: var(--err-bg); } .report .error b { color: var(--err); }
.report .warn { background: var(--warn-bg); } .report .warn b { color: var(--warn); }
.report .info { background: var(--info-bg); } .report .info b { color: var(--info); }
.report .pass { background: transparent; padding: 2px 12px; } .report .pass b { font-weight: 500; color: var(--ok); }
.controls { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 4px; }
.controls h3 output { color: var(--primary); }
input[type=range] { width: 100%; accent-color: var(--primary); }
.slider { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 8px; font-size: 14px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.swatch.active { outline: 3px solid var(--primary); outline-offset: 2px; }
.swatch-input { width: 38px; height: 38px; border: none; background: none; padding: 0; cursor: pointer; }
.sheet-wrap { background: var(--bg); border-radius: 12px; padding: 12px; text-align: center; }
#sheet-canvas { max-width: 100%; max-height: 420px; box-shadow: 0 2px 10px rgba(0,0,0,.2); background: #fff; }

/* 相機 */
.camera { position: fixed; inset: 0; z-index: 20; background: #000; }
.camera video, .camera #camera-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
video.mirror { transform: scaleX(-1); }
.camera-hint {
  position: absolute; left: 50%; top: calc(16px + env(safe-area-inset-top)); transform: translateX(-50%);
  background: rgba(0,0,0,.6); color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 700; white-space: nowrap;
}
.camera-hint[data-state=good] { background: rgba(22,163,74,.85); }
.camera-hint[data-state=warn], .camera-hint[data-state=bad] { background: rgba(217,119,6,.85); }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 120px; font-weight: 800; color: #fff; text-shadow: 0 2px 20px #000; pointer-events: none; }
.camera-bar {
  position: absolute; left: 0; right: 0; bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-around; align-items: center;
}
.camera-options { position: absolute; left: 0; right: 0; bottom: calc(110px + env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 16px; color: #fff; align-items: center; font-size: 14px; }
.camera-options .btn { color: #fff; border-color: rgba(255,255,255,.5); }
.btn.round { width: 52px; height: 52px; border-radius: 50%; justify-content: center; padding: 0; background: rgba(255,255,255,.2); color: #fff; border: none; font-size: 20px; }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.35); cursor: pointer; }
.shutter:active { background: #fff; }

.busy { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55); display: grid; place-content: center; justify-items: center; color: #fff; gap: 12px; text-align: center; padding: 16px; }
.spinner { width: 48px; height: 48px; border: 5px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.update-bar {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 25;
  background: var(--primary); color: #fff; padding: 8px 8px 8px 16px; border-radius: 999px; display: flex; gap: 10px; align-items: center; box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.notice { background: var(--warn-bg); color: var(--text); border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 8px; }
.notice b { color: var(--warn); }
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--card); color: var(--text); border-radius: 16px; padding: 20px; max-width: 420px; width: 100%; max-height: 90vh; overflow: auto; }
.modal-box h3 { margin: 0 0 8px; font-size: 18px; }
.modal-box ol, .modal-box p { font-size: 14px; margin: 6px 0; padding-left: 20px; }
.modal-box p { padding-left: 0; }
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area img { display: block; }
  body { background: #fff; }
}
[hidden] { display: none !important; }
