:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #68736e;
  --line: #dce2de;
  --paper: #ffffff;
  --canvas: #eef1ee;
  --green: #167a59;
  --green-dark: #105d45;
  --amber: #c27a12;
  --red: #b74236;
  --blue: #2879c8;
}

* { box-sizing: border-box; }
html { background: #f7f8f5; }
body {
  margin: 0;
  color: var(--ink);
  background: #f7f8f5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  max-width: 720px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.eyebrow { margin: 0 0 3px; color: var(--muted); font-size: 12px; font-weight: 650; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 22px; line-height: 1.25; }
h2 { font-size: 20px; }
.version { color: var(--green); border: 1px solid #a8d3c3; padding: 5px 9px; font-size: 12px; border-radius: 4px; }
main { max-width: 720px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.active { display: block; }

.capture-guide {
  min-height: 218px;
  background: #e3ebe5;
  display: grid;
  grid-template-columns: 46% 54%;
  align-items: center;
  overflow: hidden;
  border: 1px solid #d3ded7;
  border-radius: 8px;
}
.guide-visual { height: 218px; position: relative; background: #d4dfd7; overflow: hidden; }
.coin-demo {
  position: absolute; width: 57px; height: 57px; left: 18px; top: 21px; border-radius: 50%;
  display: grid; place-items: center; background: #bac0bd; border: 4px solid #a1aaa5; color: #66706b; font-weight: 750; font-size: 15px;
  box-shadow: inset 0 0 0 2px #d4d8d6;
}
.bead { position: absolute; border-radius: 50%; background: radial-gradient(circle at 32% 27%, #eff8f5 0 8%, #77ad9f 22%, #31816c 70%, #165947); box-shadow: 0 4px 8px #46615855; }
.b1 { width: 34px; height: 34px; top: 99px; left: 25px; }
.b2 { width: 43px; height: 43px; top: 87px; left: 77px; }
.b3 { width: 31px; height: 31px; top: 148px; left: 57px; }
.b4 { width: 39px; height: 39px; top: 145px; left: 106px; }
.b5 { width: 29px; height: 29px; top: 45px; left: 103px; }
.b6 { width: 24px; height: 24px; top: 118px; left: 139px; }
.guide-copy { padding: 25px 20px; }
.guide-copy h2 { margin-bottom: 9px; }
.guide-copy p { margin: 0; color: #53615a; font-size: 14px; line-height: 1.65; }

.requirements { margin: 16px 2px 20px; }
.requirements > div { display: flex; gap: 11px; align-items: flex-start; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.requirements p { margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.requirements small { color: var(--muted); font-size: 12px; }
.check { flex: 0 0 23px; height: 23px; display: grid; place-items: center; color: var(--green); background: #dff0e9; border-radius: 50%; font-size: 13px; font-weight: 800; }

.primary-button {
  min-height: 52px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  color: white; background: var(--green); border: 0; border-radius: 6px; font-size: 16px; font-weight: 700;
  box-shadow: 0 3px 10px #146f5126;
}
.primary-button:active { background: var(--green-dark); }
.camera-icon { width: 21px; height: 16px; border: 2px solid currentColor; border-radius: 3px; position: relative; }
.camera-icon::before { content: ""; position: absolute; width: 7px; height: 7px; border: 2px solid currentColor; border-radius: 50%; left: 5px; top: 2px; }
.camera-icon::after { content: ""; position: absolute; width: 8px; height: 3px; border-radius: 2px 2px 0 0; background: currentColor; left: 4px; top: -5px; }
.privacy { margin: 12px 8px 0; color: var(--muted); font-size: 11px; text-align: center; line-height: 1.55; }

.loading-view, .done-view { text-align: center; padding: 90px 24px; }
.spinner { width: 46px; height: 46px; margin: 0 auto 22px; border: 4px solid #d9e3dd; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-view p, .done-view p { color: var(--muted); font-size: 14px; line-height: 1.6; }

.result-head { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px; margin-bottom: 14px; }
.result-head h2 { margin: 0; font-size: 26px; }
.icon-button, .danger-icon { width: 40px; height: 40px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 5px; font-size: 30px; line-height: 1; }
.confidence-badge { padding: 6px 9px; background: #fff0d7; color: #8a5811; border-radius: 4px; font-size: 12px; font-weight: 700; }
.warning-box { margin-bottom: 12px; padding: 10px 12px; color: #70470d; background: #fff5e5; border-left: 3px solid var(--amber); font-size: 13px; line-height: 1.5; }
.canvas-shell { position: relative; min-height: 220px; background: #d8ddda; overflow: hidden; border-radius: 6px; touch-action: manipulation; }
.canvas-shell img { width: 100%; height: auto; display: block; }
.canvas-shell canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.canvas-tip { position: absolute; left: 50%; bottom: 9px; transform: translateX(-50%); width: max-content; max-width: 90%; padding: 6px 9px; background: #111b18c7; color: white; border-radius: 4px; font-size: 11px; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 13px; padding: 10px 2px; color: var(--muted); font-size: 11px; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; }
.dot.certain { background: var(--green); }.dot.uncertain { background: var(--amber); }.dot.selected { background: var(--blue); }

.editor { padding: 15px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; }
.editor-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.editor-title h3 { margin: 0; font-size: 18px; }
.danger-icon { color: var(--red); font-size: 24px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row label, .select-field, .note-field { color: var(--muted); font-size: 12px; }
input[type="number"], select, textarea { width: 100%; margin-top: 6px; padding: 11px 10px; color: var(--ink); background: white; border: 1px solid #cfd7d2; border-radius: 4px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 2px #167a591a; }
.select-field { display: block; margin-top: 11px; }
.confirm-row { margin-top: 13px; display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; }
.confirm-row input { width: 19px; height: 19px; accent-color: var(--green); }
.note-field { display: block; margin-top: 15px; }
.note-field textarea { resize: vertical; }
.button-element { margin-top: 14px; }
.text-button { display: block; margin: 16px auto 0; border: 0; background: none; color: var(--green); padding: 8px 16px; }
.done-mark { width: 58px; height: 58px; margin: 0 auto 20px; display: grid; place-items: center; color: white; background: var(--green); border-radius: 50%; font-size: 28px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 14px; color: white; background: #17201dea; border-radius: 5px; font-size: 13px; transition: .2s; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 390px) {
  .capture-guide { grid-template-columns: 44% 56%; }
  .guide-copy { padding: 20px 14px; }
  .guide-copy h2 { font-size: 18px; }
  .b6 { display: none; }
}
@media (min-width: 720px) {
  main { padding-left: 0; padding-right: 0; }
}
