Khunndev Cursor commited on
Commit
445c3cc
Β·
1 Parent(s): 7a0d096

Improve UX/UI for native mobile app feel

Browse files

Co-authored-by: Cursor <cursoragent@cursor.com>

frontend/src/App.tsx CHANGED
@@ -10,6 +10,8 @@ import { StepResults } from './components/StepResults'
10
 
11
  type Step = 'capture' | 'preview' | 'counting' | 'results'
12
 
 
 
13
  export default function App() {
14
  const [step, setStep] = useState<Step>('capture')
15
  const [lang, setLang] = useState<Lang>('th')
@@ -110,95 +112,133 @@ export default function App() {
110
  }
111
 
112
  // -------------------------------------------------------------------------
113
- // wizard step indicator dots
114
  // -------------------------------------------------------------------------
115
- const STEPS: Step[] = ['capture', 'preview', 'counting', 'results']
116
  const stepIdx = STEPS.indexOf(step)
117
 
118
  return (
119
- <div className="fixed inset-0 flex flex-col overflow-hidden bg-slate-950">
120
- {/* minimal header */}
121
- <header className="flex shrink-0 items-center justify-between border-b border-slate-800/60 px-4 pb-2.5 pt-[max(0.625rem,env(safe-area-inset-top))]">
 
 
 
 
 
 
 
122
  <div className="flex items-center gap-2.5">
123
- <img src="/icon.svg" alt="" className="h-7 w-7 rounded-lg" />
124
- <span className="text-sm font-semibold text-white">{t(lang, 'title')}</span>
 
 
 
 
 
 
 
 
 
125
  </div>
126
 
127
- {/* step dots */}
128
- <div className="flex items-center gap-1.5">
129
  {STEPS.map((s, i) => (
130
  <span
131
  key={s}
132
- className={`h-1.5 rounded-full transition-all duration-300 ${
133
- i === stepIdx ? 'w-5 bg-emerald-400' : i < stepIdx ? 'w-1.5 bg-slate-500' : 'w-1.5 bg-slate-700'
 
 
 
 
134
  }`}
135
  />
136
  ))}
137
  </div>
138
 
 
139
  <button
140
  type="button"
141
- className="rounded-lg bg-slate-800 px-3 py-1.5 text-xs font-medium text-slate-200 active:scale-95"
142
  onClick={() => setLang(lang === 'th' ? 'en' : 'th')}
143
  >
144
- {lang === 'th' ? 'EN' : 'TH'}
145
  </button>
 
 
 
146
  </header>
147
 
148
- {/* steps */}
149
- {step === 'capture' && (
150
- <StepCapture
151
- lang={lang}
152
- modelReady={modelReady}
153
- onCamera={() => cameraRef.current?.click()}
154
- onGallery={() => fileRef.current?.click()}
155
- />
156
- )}
157
-
158
- {step === 'preview' && image && (
159
- <StepPreview
160
- lang={lang}
161
- imageSrc={imageSrc}
162
- imageDims={imageDims}
163
- busy={busy}
164
- modelReady={modelReady}
165
- groupCount={groupCount}
166
- enhanceImage={enhanceImage}
167
- useTiling={useTiling}
168
- filterOutliers={filterOutliers}
169
- onBack={resetToCapture}
170
- onRetake={() => cameraRef.current?.click()}
171
- onGallery={() => fileRef.current?.click()}
172
- onCount={runCount}
173
- onGroupCount={setGroupCount}
174
- onEnhanceImage={setEnhanceImage}
175
- onUseTiling={setUseTiling}
176
- onFilterOutliers={setFilterOutliers}
177
- onRecluster={recluster}
178
- />
179
- )}
180
-
181
- {step === 'counting' && (
182
- <StepCounting lang={lang} status={status} imageSrc={imageSrc} />
183
- )}
184
-
185
- {step === 'results' && image && (
186
- <StepResults
187
- lang={lang}
188
- image={image}
189
- detections={detections}
190
- groups={groups}
191
- counts={counts}
192
- onUpdate={setDetections}
193
- onExpectedChange={handleExpectedChange}
194
- onRecount={() => { setStep('preview') }}
195
- onNewPhoto={resetToCapture}
196
- />
197
- )}
198
-
199
- {/* hidden file inputs */}
200
- <input ref={fileRef} type="file" accept="image/*" className="hidden" onChange={(e) => e.target.files?.[0] && loadFile(e.target.files[0])} />
201
- <input ref={cameraRef} type="file" accept="image/*" capture="environment" className="hidden" onChange={(e) => e.target.files?.[0] && loadFile(e.target.files[0])} />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  </div>
203
  )
204
  }
 
10
 
11
  type Step = 'capture' | 'preview' | 'counting' | 'results'
12
 
13
+ const STEPS: Step[] = ['capture', 'preview', 'counting', 'results']
14
+
15
  export default function App() {
16
  const [step, setStep] = useState<Step>('capture')
17
  const [lang, setLang] = useState<Lang>('th')
 
112
  }
113
 
114
  // -------------------------------------------------------------------------
115
+ // header step indicator
116
  // -------------------------------------------------------------------------
 
117
  const stepIdx = STEPS.indexOf(step)
118
 
119
  return (
120
+ <div className="fixed inset-0 flex flex-col overflow-hidden bg-[#020617]">
121
+ {/* ── Header ──────────────────────────────────────────────────── */}
122
+ <header
123
+ className="relative flex shrink-0 items-center justify-between bg-[#020617] px-4"
124
+ style={{
125
+ paddingTop: 'max(0.75rem, env(safe-area-inset-top))',
126
+ paddingBottom: '0.625rem',
127
+ }}
128
+ >
129
+ {/* App brand */}
130
  <div className="flex items-center gap-2.5">
131
+ <div className="relative">
132
+ <img src="/icon.svg" alt="" className="h-7 w-7 rounded-xl" />
133
+ <span
134
+ className={`absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full border-2 border-[#020617] transition-colors duration-700 ${
135
+ modelReady ? 'bg-emerald-400' : 'animate-pulse bg-amber-400'
136
+ }`}
137
+ />
138
+ </div>
139
+ <span className="text-[15px] font-semibold tracking-tight text-white">
140
+ {t(lang, 'title')}
141
+ </span>
142
  </div>
143
 
144
+ {/* Step progress pills */}
145
+ <div className="flex items-center gap-1">
146
  {STEPS.map((s, i) => (
147
  <span
148
  key={s}
149
+ className={`h-1 rounded-full transition-all duration-500 ease-out ${
150
+ i === stepIdx
151
+ ? 'w-6 bg-white'
152
+ : i < stepIdx
153
+ ? 'w-2 bg-white/40'
154
+ : 'w-2 bg-white/15'
155
  }`}
156
  />
157
  ))}
158
  </div>
159
 
160
+ {/* Lang toggle */}
161
  <button
162
  type="button"
163
+ className="rounded-lg bg-white/8 px-3 py-1.5 text-xs font-semibold text-white/70 transition-all duration-150 active:scale-95 active:bg-white/15"
164
  onClick={() => setLang(lang === 'th' ? 'en' : 'th')}
165
  >
166
+ {lang === 'th' ? 'EN' : 'ΰΈ '}
167
  </button>
168
+
169
+ {/* Bottom separator β€” subtle gradient line */}
170
+ <div className="absolute inset-x-0 bottom-0 h-px bg-gradient-to-r from-transparent via-white/10 to-transparent" />
171
  </header>
172
 
173
+ {/* ── Step views β€” key forces remount β†’ triggers step-enter CSS animation ── */}
174
+ <div key={step} className="step-enter flex flex-1 flex-col overflow-hidden">
175
+ {step === 'capture' && (
176
+ <StepCapture
177
+ lang={lang}
178
+ modelReady={modelReady}
179
+ onCamera={() => cameraRef.current?.click()}
180
+ onGallery={() => fileRef.current?.click()}
181
+ />
182
+ )}
183
+
184
+ {step === 'preview' && image && (
185
+ <StepPreview
186
+ lang={lang}
187
+ imageSrc={imageSrc}
188
+ imageDims={imageDims}
189
+ busy={busy}
190
+ modelReady={modelReady}
191
+ groupCount={groupCount}
192
+ enhanceImage={enhanceImage}
193
+ useTiling={useTiling}
194
+ filterOutliers={filterOutliers}
195
+ onBack={resetToCapture}
196
+ onRetake={() => cameraRef.current?.click()}
197
+ onGallery={() => fileRef.current?.click()}
198
+ onCount={runCount}
199
+ onGroupCount={setGroupCount}
200
+ onEnhanceImage={setEnhanceImage}
201
+ onUseTiling={setUseTiling}
202
+ onFilterOutliers={setFilterOutliers}
203
+ onRecluster={recluster}
204
+ />
205
+ )}
206
+
207
+ {step === 'counting' && (
208
+ <StepCounting lang={lang} status={status} imageSrc={imageSrc} />
209
+ )}
210
+
211
+ {step === 'results' && image && (
212
+ <StepResults
213
+ lang={lang}
214
+ image={image}
215
+ detections={detections}
216
+ groups={groups}
217
+ counts={counts}
218
+ onUpdate={setDetections}
219
+ onExpectedChange={handleExpectedChange}
220
+ onRecount={() => { setStep('preview') }}
221
+ onNewPhoto={resetToCapture}
222
+ />
223
+ )}
224
+ </div>
225
+
226
+ {/* ── Hidden file inputs ─────────────────────────────────────── */}
227
+ <input
228
+ ref={fileRef}
229
+ type="file"
230
+ accept="image/*"
231
+ className="hidden"
232
+ onChange={(e) => e.target.files?.[0] && loadFile(e.target.files[0])}
233
+ />
234
+ <input
235
+ ref={cameraRef}
236
+ type="file"
237
+ accept="image/*"
238
+ capture="environment"
239
+ className="hidden"
240
+ onChange={(e) => e.target.files?.[0] && loadFile(e.target.files[0])}
241
+ />
242
  </div>
243
  )
244
  }
frontend/src/components/ExportSheet.tsx CHANGED
@@ -23,57 +23,87 @@ export function ExportSheet({
23
  canExportPng,
24
  canExportData,
25
  }: Props) {
26
- if (!open) {
27
- return null
28
- }
29
 
30
  return (
31
  <>
 
32
  <button
33
  type="button"
34
- className="fixed inset-0 z-50 bg-slate-950/60 backdrop-blur-sm"
35
  aria-label="Close"
36
  onClick={onClose}
37
  />
38
- <div className="fixed inset-x-0 bottom-0 z-50 rounded-t-2xl border-t border-slate-700 bg-slate-900 px-4 pt-4 pb-[max(1rem,env(safe-area-inset-bottom))] shadow-2xl">
39
- <div className="mx-auto mb-4 h-1 w-10 rounded-full bg-slate-600" />
40
- <h2 className="mb-4 text-center text-base font-semibold text-white">{t(lang, 'export')}</h2>
41
- <div className="mx-auto flex max-w-lg flex-col gap-2">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  <button
43
  type="button"
44
  disabled={!canExportPng}
45
- className="flex min-h-12 items-center gap-3 rounded-xl bg-slate-800 px-4 text-left text-sm font-medium disabled:opacity-50 active:bg-slate-700"
46
- onClick={() => {
47
- onExportPng()
48
- onClose()
49
- }}
50
  >
51
- <Image size={20} className="text-blue-400" />
52
- {t(lang, 'exportPng')}
 
 
53
  </button>
 
 
 
 
54
  <button
55
  type="button"
56
  disabled={!canExportData}
57
- className="flex min-h-12 items-center gap-3 rounded-xl bg-slate-800 px-4 text-left text-sm font-medium disabled:opacity-50 active:bg-slate-700"
58
- onClick={() => {
59
- onExportJson()
60
- onClose()
61
- }}
62
  >
63
- <FileJson size={20} className="text-amber-400" />
64
- {t(lang, 'exportJson')}
 
 
65
  </button>
 
 
 
 
66
  <button
67
  type="button"
68
  disabled={!canExportData}
69
- className="flex min-h-12 items-center gap-3 rounded-xl bg-slate-800 px-4 text-left text-sm font-medium disabled:opacity-50 active:bg-slate-700"
70
- onClick={() => {
71
- onExportCsv()
72
- onClose()
73
- }}
 
 
 
 
 
 
 
 
 
 
 
74
  >
75
- <FileSpreadsheet size={20} className="text-emerald-400" />
76
- {t(lang, 'exportCsv')}
77
  </button>
78
  </div>
79
  </div>
 
23
  canExportPng,
24
  canExportData,
25
  }: Props) {
26
+ if (!open) return null
 
 
27
 
28
  return (
29
  <>
30
+ {/* Backdrop */}
31
  <button
32
  type="button"
33
+ className="overlay-enter fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"
34
  aria-label="Close"
35
  onClick={onClose}
36
  />
37
+
38
+ {/* Sheet */}
39
+ <div
40
+ className="sheet-enter fixed inset-x-0 bottom-0 z-50 rounded-t-[1.75rem] bg-[#111827] ring-1 ring-white/10 shadow-2xl"
41
+ style={{ paddingBottom: 'max(1.25rem, env(safe-area-inset-bottom))' }}
42
+ >
43
+ {/* Drag handle */}
44
+ <div className="flex justify-center pt-3 pb-1">
45
+ <div className="h-1 w-9 rounded-full bg-white/20" />
46
+ </div>
47
+
48
+ {/* Title */}
49
+ <h2 className="px-5 pb-3 pt-2 text-center text-[17px] font-semibold text-white">
50
+ {t(lang, 'export')}
51
+ </h2>
52
+
53
+ {/* Actions */}
54
+ <div className="mx-4 overflow-hidden rounded-2xl bg-white/5 ring-1 ring-white/8">
55
+ {/* PNG */}
56
  <button
57
  type="button"
58
  disabled={!canExportPng}
59
+ className="flex min-h-[52px] w-full items-center gap-4 px-4 text-left transition-colors duration-150 disabled:opacity-40 active:bg-white/8"
60
+ onClick={() => { onExportPng(); onClose() }}
 
 
 
61
  >
62
+ <span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-blue-500/20">
63
+ <Image size={18} className="text-blue-400" />
64
+ </span>
65
+ <span className="text-[15px] font-medium text-white/90">{t(lang, 'exportPng')}</span>
66
  </button>
67
+
68
+ <div className="ml-[3.25rem] h-px bg-white/8" />
69
+
70
+ {/* JSON */}
71
  <button
72
  type="button"
73
  disabled={!canExportData}
74
+ className="flex min-h-[52px] w-full items-center gap-4 px-4 text-left transition-colors duration-150 disabled:opacity-40 active:bg-white/8"
75
+ onClick={() => { onExportJson(); onClose() }}
 
 
 
76
  >
77
+ <span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-amber-500/20">
78
+ <FileJson size={18} className="text-amber-400" />
79
+ </span>
80
+ <span className="text-[15px] font-medium text-white/90">{t(lang, 'exportJson')}</span>
81
  </button>
82
+
83
+ <div className="ml-[3.25rem] h-px bg-white/8" />
84
+
85
+ {/* CSV */}
86
  <button
87
  type="button"
88
  disabled={!canExportData}
89
+ className="flex min-h-[52px] w-full items-center gap-4 px-4 text-left transition-colors duration-150 disabled:opacity-40 active:bg-white/8"
90
+ onClick={() => { onExportCsv(); onClose() }}
91
+ >
92
+ <span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-emerald-500/20">
93
+ <FileSpreadsheet size={18} className="text-emerald-400" />
94
+ </span>
95
+ <span className="text-[15px] font-medium text-white/90">{t(lang, 'exportCsv')}</span>
96
+ </button>
97
+ </div>
98
+
99
+ {/* Cancel */}
100
+ <div className="mx-4 mt-2.5">
101
+ <button
102
+ type="button"
103
+ className="flex min-h-[50px] w-full items-center justify-center rounded-2xl bg-white/7 text-[15px] font-semibold text-white/70 transition-colors duration-150 active:bg-white/12"
104
+ onClick={onClose}
105
  >
106
+ Cancel
 
107
  </button>
108
  </div>
109
  </div>
frontend/src/components/GroupPanel.tsx CHANGED
@@ -22,51 +22,72 @@ export function GroupPanel({
22
  }: Props) {
23
  return (
24
  <section>
25
- <h3 className="mb-2 text-xs font-medium uppercase tracking-wide text-slate-500">{t(lang, 'groups')}</h3>
26
- <div className="flex gap-3 overflow-x-auto pb-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden lg:flex-col lg:overflow-visible">
27
- {groups.map((g) => {
 
 
 
28
  const count = counts[g.id] ?? 0
29
  const mismatch = g.expected !== undefined && g.expected !== count
30
  const selected = selectedGroupId === g.id
 
31
  return (
32
- <button
33
- key={g.id}
34
- type="button"
35
- onClick={() => onSelectGroup(g.id)}
36
- className={cn(
37
- 'w-[min(85vw,280px)] shrink-0 rounded-2xl border p-4 text-left transition active:scale-[0.99] lg:w-full',
38
- selected
39
- ? 'border-white/40 bg-slate-800 ring-1 ring-white/20'
40
- : 'border-slate-700/80 bg-slate-900/60',
41
- )}
42
- >
43
- <div className="flex items-center gap-2">
44
- <span className="h-3.5 w-3.5 rounded-full ring-2 ring-slate-700" style={{ background: g.color }} />
45
- <span className="font-medium text-slate-100">{g.label}</span>
46
- <span className="ml-auto text-2xl font-bold tabular-nums text-white">{count}</span>
47
- </div>
48
- <div className="mt-3 flex items-center gap-2 text-xs text-slate-400">
49
- <label htmlFor={`exp-${g.id}`}>{t(lang, 'expected')}:</label>
50
- <input
51
- id={`exp-${g.id}`}
52
- type="number"
53
- inputMode="numeric"
54
- min={0}
55
- className="h-9 w-20 rounded-lg border border-slate-600 bg-slate-950 px-2 text-sm text-white"
56
- value={g.expected ?? ''}
57
- onChange={(e) => {
58
- const v = e.target.value
59
- onExpectedChange(g.id, v === '' ? undefined : Number(v))
60
- }}
61
- onClick={(e) => e.stopPropagation()}
62
  />
63
- {mismatch && <span className="font-medium text-amber-400">{t(lang, 'mismatch')}</span>}
64
- </div>
65
- </button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  )
67
  })}
68
  </div>
69
- <p className="mt-2 text-xs text-slate-500">{t(lang, 'selectGroup')}</p>
 
70
  </section>
71
  )
72
  }
 
22
  }: Props) {
23
  return (
24
  <section>
25
+ <p className="mb-2 px-1 text-[11px] font-medium uppercase tracking-widest text-white/30">
26
+ {t(lang, 'groups')}
27
+ </p>
28
+
29
+ <div className="overflow-hidden rounded-2xl bg-white/6 ring-1 ring-white/8">
30
+ {groups.map((g, idx) => {
31
  const count = counts[g.id] ?? 0
32
  const mismatch = g.expected !== undefined && g.expected !== count
33
  const selected = selectedGroupId === g.id
34
+
35
  return (
36
+ <div key={g.id}>
37
+ {idx > 0 && <div className="ml-4 h-px bg-white/8" />}
38
+
39
+ <button
40
+ type="button"
41
+ onClick={() => onSelectGroup(g.id)}
42
+ className={cn(
43
+ 'flex min-h-[56px] w-full items-center gap-3 px-4 text-left transition-colors duration-150',
44
+ selected ? 'bg-white/8' : 'active:bg-white/5',
45
+ )}
46
+ >
47
+ {/* Color swatch */}
48
+ <span
49
+ className="h-3 w-3 shrink-0 rounded-full ring-2 ring-white/20"
50
+ style={{ background: g.color }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  />
52
+
53
+ {/* Label */}
54
+ <span className="flex-1 text-[15px] text-white/90">{g.label}</span>
55
+
56
+ {/* Expected input */}
57
+ <div className="flex items-center gap-2" onClick={(e) => e.stopPropagation()}>
58
+ {mismatch && (
59
+ <span className="text-xs font-semibold text-amber-400">β‰ {g.expected}</span>
60
+ )}
61
+ <input
62
+ type="number"
63
+ inputMode="numeric"
64
+ min={0}
65
+ placeholder={t(lang, 'expected')}
66
+ className="h-8 w-20 rounded-xl border border-white/12 bg-white/8 px-2.5 text-center text-sm text-white placeholder:text-white/25 focus:outline-none focus:ring-1 focus:ring-white/30"
67
+ value={g.expected ?? ''}
68
+ onChange={(e) => {
69
+ const v = e.target.value
70
+ onExpectedChange(g.id, v === '' ? undefined : Number(v))
71
+ }}
72
+ />
73
+ </div>
74
+
75
+ {/* Count */}
76
+ <span
77
+ className={cn(
78
+ 'min-w-[2.5rem] text-right text-2xl font-bold tabular-nums leading-none',
79
+ mismatch ? 'text-amber-400' : 'text-white',
80
+ )}
81
+ >
82
+ {count}
83
+ </span>
84
+ </button>
85
+ </div>
86
  )
87
  })}
88
  </div>
89
+
90
+ <p className="mt-1.5 px-1 text-[11px] text-white/25">{t(lang, 'selectGroup')}</p>
91
  </section>
92
  )
93
  }
frontend/src/components/SettingsPanel.tsx CHANGED
@@ -15,31 +15,54 @@ interface Props {
15
  onRecluster: () => void
16
  }
17
 
 
18
  function Toggle({
19
  checked,
20
  onChange,
21
  label,
 
22
  }: {
23
  checked: boolean
24
  onChange: (v: boolean) => void
25
  label: string
 
26
  }) {
27
  return (
28
- <div className="flex min-h-11 items-center justify-between gap-3 rounded-xl bg-slate-800/60 px-3 py-2.5">
29
- <span className="text-sm text-slate-200">{label}</span>
30
- <button
31
- type="button"
32
- role="switch"
33
- aria-checked={checked}
34
- aria-label={label}
35
- className={`relative h-7 w-12 shrink-0 rounded-full transition-colors ${checked ? 'bg-emerald-600' : 'bg-slate-600'}`}
36
- onClick={() => onChange(!checked)}
 
 
 
 
 
 
 
 
 
 
37
  >
38
  <span
39
- className={`absolute top-0.5 left-0.5 h-6 w-6 rounded-full bg-white shadow transition-transform ${checked ? 'translate-x-5' : ''}`}
 
 
 
40
  />
41
- </button>
42
- </div>
 
 
 
 
 
 
 
43
  )
44
  }
45
 
@@ -56,49 +79,70 @@ export function SettingsPanel({
56
  onFilterOutliers,
57
  onRecluster,
58
  }: Props) {
59
- if (!open) {
60
- return null
61
- }
62
 
63
  return (
64
- <section className="rounded-2xl border border-slate-700/80 bg-slate-900/60 p-4">
65
- <h2 className="mb-3 text-sm font-semibold text-slate-300">{t(lang, 'settings')}</h2>
66
-
67
- <div className="mb-4">
68
- <p className="mb-2 text-xs text-slate-500">{t(lang, 'groupCount')}</p>
69
- <div className="flex flex-wrap gap-2">
70
- <button
71
- type="button"
72
- className={`min-h-10 rounded-lg px-3 text-sm font-medium ${groupCount === 'auto' ? 'bg-blue-600 text-white' : 'bg-slate-800 text-slate-300'}`}
73
- onClick={() => onGroupCount('auto')}
74
- >
75
- {t(lang, 'auto')}
76
- </button>
77
- {[1, 2, 3, 4, 5, 6].map((n) => (
 
 
 
 
 
 
 
 
 
 
 
78
  <button
79
- key={n}
80
  type="button"
81
- className={`min-h-10 min-w-10 rounded-lg text-sm font-medium ${groupCount === n ? 'bg-blue-600 text-white' : 'bg-slate-800 text-slate-300'}`}
82
- onClick={() => onGroupCount(n)}
83
  >
84
- {n}
85
  </button>
86
- ))}
87
- <button
88
- type="button"
89
- className="min-h-10 rounded-lg bg-slate-700 px-3 text-sm font-medium text-slate-200"
90
- onClick={onRecluster}
91
- >
92
- {t(lang, 'apply')}
93
- </button>
94
  </div>
95
- </div>
96
 
97
- <div className="space-y-2">
98
- <Toggle checked={enhanceImage} onChange={onEnhanceImage} label={t(lang, 'enhanceImage')} />
99
- <Toggle checked={useTiling} onChange={onUseTiling} label={t(lang, 'highAccuracy')} />
100
- <Toggle checked={filterOutliers} onChange={onFilterOutliers} label={t(lang, 'filterOutliers')} />
101
- </div>
102
- </section>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  )
104
  }
 
15
  onRecluster: () => void
16
  }
17
 
18
+ /** iOS-style toggle switch */
19
  function Toggle({
20
  checked,
21
  onChange,
22
  label,
23
+ description,
24
  }: {
25
  checked: boolean
26
  onChange: (v: boolean) => void
27
  label: string
28
+ description?: string
29
  }) {
30
  return (
31
+ <button
32
+ type="button"
33
+ role="switch"
34
+ aria-checked={checked}
35
+ className="flex min-h-[52px] w-full items-center justify-between gap-3 px-4 text-left transition-colors duration-150 active:bg-white/5"
36
+ onClick={() => onChange(!checked)}
37
+ >
38
+ <span className="flex flex-col gap-0.5">
39
+ <span className="text-[15px] text-white/90">{label}</span>
40
+ {description && (
41
+ <span className="text-xs text-white/35">{description}</span>
42
+ )}
43
+ </span>
44
+ {/* Native-size iOS toggle */}
45
+ <span
46
+ className={`relative h-[31px] w-[51px] shrink-0 rounded-full transition-colors duration-200 ${
47
+ checked ? 'bg-[#34c759]' : 'bg-white/20'
48
+ }`}
49
+ style={{ boxShadow: 'inset 0 0 0 1px rgba(0,0,0,0.2)' }}
50
  >
51
  <span
52
+ className={`absolute top-[2px] h-[27px] w-[27px] rounded-full bg-white shadow-md transition-all duration-200 ${
53
+ checked ? 'left-[22px]' : 'left-[2px]'
54
+ }`}
55
+ style={{ boxShadow: '0 2px 6px rgba(0,0,0,0.3)' }}
56
  />
57
+ </span>
58
+ </button>
59
+ )
60
+ }
61
+
62
+ /** Inset separator line between list rows */
63
+ function Separator() {
64
+ return (
65
+ <div className="ml-4 h-px bg-white/8" />
66
  )
67
  }
68
 
 
79
  onFilterOutliers,
80
  onRecluster,
81
  }: Props) {
82
+ if (!open) return null
 
 
83
 
84
  return (
85
+ <div className="space-y-4">
86
+ {/* ── Group count section ──────────────────────────────────── */}
87
+ <section>
88
+ <p className="mb-2 px-1 text-xs font-medium uppercase tracking-widest text-white/35">
89
+ {t(lang, 'groupCount')}
90
+ </p>
91
+ <div className="overflow-hidden rounded-2xl bg-white/6 ring-1 ring-white/8">
92
+ <div className="flex flex-wrap gap-2 p-3">
93
+ {(['auto', 1, 2, 3, 4, 5, 6] as (number | 'auto')[]).map((n) => {
94
+ const active = groupCount === n
95
+ return (
96
+ <button
97
+ key={String(n)}
98
+ type="button"
99
+ className={`min-h-9 rounded-xl px-4 text-sm font-semibold transition-all duration-150 active:scale-95 ${
100
+ active
101
+ ? 'bg-blue-500 text-white shadow-md shadow-blue-900/40'
102
+ : 'bg-white/8 text-white/65 active:bg-white/15'
103
+ }`}
104
+ onClick={() => onGroupCount(n)}
105
+ >
106
+ {n === 'auto' ? t(lang, 'auto') : n}
107
+ </button>
108
+ )
109
+ })}
110
  <button
 
111
  type="button"
112
+ className="min-h-9 rounded-xl bg-white/8 px-4 text-sm font-semibold text-white/65 transition-all duration-150 active:scale-95 active:bg-white/15"
113
+ onClick={onRecluster}
114
  >
115
+ {t(lang, 'apply')}
116
  </button>
117
+ </div>
 
 
 
 
 
 
 
118
  </div>
119
+ </section>
120
 
121
+ {/* ── Toggle settings section ──────────────────────────────── */}
122
+ <section>
123
+ <p className="mb-2 px-1 text-xs font-medium uppercase tracking-widest text-white/35">
124
+ {t(lang, 'settings')}
125
+ </p>
126
+ <div className="overflow-hidden rounded-2xl bg-white/6 ring-1 ring-white/8">
127
+ <Toggle
128
+ checked={enhanceImage}
129
+ onChange={onEnhanceImage}
130
+ label={t(lang, 'enhanceImage')}
131
+ />
132
+ <Separator />
133
+ <Toggle
134
+ checked={useTiling}
135
+ onChange={onUseTiling}
136
+ label={t(lang, 'highAccuracy')}
137
+ />
138
+ <Separator />
139
+ <Toggle
140
+ checked={filterOutliers}
141
+ onChange={onFilterOutliers}
142
+ label={t(lang, 'filterOutliers')}
143
+ />
144
+ </div>
145
+ </section>
146
+ </div>
147
  )
148
  }
frontend/src/components/StepCapture.tsx CHANGED
@@ -11,47 +11,109 @@ interface Props {
11
 
12
  export function StepCapture({ lang, modelReady, onCamera, onGallery }: Props) {
13
  return (
14
- <div className="flex flex-1 flex-col items-center justify-center px-6">
15
- {/* logo mark */}
16
- <div className="mb-8 flex flex-col items-center gap-3">
17
- <div className="relative flex h-24 w-24 items-center justify-center rounded-3xl bg-gradient-to-br from-slate-800 to-slate-900 shadow-2xl ring-1 ring-slate-700">
18
- <img src="/icon.svg" alt="" className="h-16 w-16" />
19
- {/* model ready indicator */}
20
- <span
21
- className={`absolute -right-1 -top-1 h-4 w-4 rounded-full border-2 border-slate-950 ${
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  modelReady
23
- ? 'bg-emerald-400 shadow-[0_0_10px_rgba(52,211,153,0.7)]'
24
- : 'animate-pulse bg-amber-400'
25
  }`}
26
- />
 
 
 
 
 
 
 
27
  </div>
28
- <div className="text-center">
29
- <h1 className="text-2xl font-bold tracking-tight text-white">{t(lang, 'title')}</h1>
30
- <p className="mt-1 text-sm text-slate-400">{t(lang, 'captureSubtitle')}</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  </div>
32
  </div>
33
 
34
- {/* action buttons */}
35
- <div className="w-full max-w-xs space-y-3">
36
- <button
37
- type="button"
38
- className="flex h-14 w-full items-center justify-center gap-3 rounded-2xl bg-blue-600 text-base font-bold text-white shadow-lg shadow-blue-900/40 active:scale-[0.98]"
39
- onClick={onCamera}
40
- >
41
- <Camera size={22} />
42
- {t(lang, 'takePhoto')}
43
- </button>
44
- <button
45
- type="button"
46
- className="flex h-14 w-full items-center justify-center gap-3 rounded-2xl bg-slate-800 text-base font-medium text-slate-200 ring-1 ring-slate-700 active:scale-[0.98]"
47
- onClick={onGallery}
48
- >
49
- <ImagePlus size={22} />
50
- {t(lang, 'chooseFile')}
51
- </button>
52
  </div>
53
-
54
- <p className="mt-10 text-center text-xs text-slate-600">{t(lang, 'company')}</p>
55
  </div>
56
  )
57
  }
 
11
 
12
  export function StepCapture({ lang, modelReady, onCamera, onGallery }: Props) {
13
  return (
14
+ <div className="relative flex flex-1 flex-col overflow-hidden">
15
+ {/* Background ambient glow */}
16
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center">
17
+ <div
18
+ className="h-[420px] w-[420px] rounded-full"
19
+ style={{
20
+ background: 'radial-gradient(circle, rgba(59,130,246,0.18) 0%, rgba(16,185,129,0.06) 50%, transparent 70%)',
21
+ animation: 'glow-pulse 4s ease-in-out infinite',
22
+ }}
23
+ />
24
+ </div>
25
+
26
+ {/* Hero area */}
27
+ <div className="relative z-10 flex flex-1 flex-col items-center justify-center px-8">
28
+ {/* Logo mark */}
29
+ <div className="mb-8 flex flex-col items-center gap-4">
30
+ <div className="relative">
31
+ {/* Outer glow ring */}
32
+ <div
33
+ className="absolute -inset-4 rounded-full opacity-40"
34
+ style={{
35
+ background: 'radial-gradient(circle, rgba(59,130,246,0.5) 0%, transparent 70%)',
36
+ animation: 'breathe 3.5s ease-in-out infinite',
37
+ }}
38
+ />
39
+ {/* Icon container */}
40
+ <div
41
+ className="relative flex h-28 w-28 items-center justify-center rounded-[2rem] bg-gradient-to-br from-slate-800 to-slate-900 shadow-2xl ring-1 ring-white/10"
42
+ style={{ animation: 'breathe 3.5s ease-in-out infinite' }}
43
+ >
44
+ <img src="/icon.svg" alt="" className="h-18 w-18" style={{ width: 72, height: 72 }} />
45
+
46
+ {/* Model-ready dot */}
47
+ <span
48
+ className={`absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full border-[3px] border-[#020617] transition-all duration-700 ${
49
+ modelReady
50
+ ? 'bg-emerald-400 shadow-[0_0_12px_rgba(52,211,153,0.8)]'
51
+ : 'animate-pulse bg-amber-400 shadow-[0_0_10px_rgba(251,191,36,0.7)]'
52
+ }`}
53
+ />
54
+ </div>
55
+ </div>
56
+
57
+ <div className="text-center">
58
+ <h1 className="text-[26px] font-bold tracking-tight text-white">
59
+ {t(lang, 'title')}
60
+ </h1>
61
+ <p className="mt-1.5 text-sm text-white/45">
62
+ {t(lang, 'captureSubtitle')}
63
+ </p>
64
+ </div>
65
+
66
+ {/* Model status badge */}
67
+ <div
68
+ className={`flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium transition-colors duration-500 ${
69
  modelReady
70
+ ? 'bg-emerald-500/15 text-emerald-300'
71
+ : 'bg-amber-500/15 text-amber-300'
72
  }`}
73
+ >
74
+ <span
75
+ className={`h-1.5 w-1.5 rounded-full ${
76
+ modelReady ? 'bg-emerald-400' : 'animate-pulse bg-amber-400'
77
+ }`}
78
+ />
79
+ {modelReady ? t(lang, 'modelReady') : t(lang, 'loadingModel')}
80
+ </div>
81
  </div>
82
+
83
+ {/* CTA buttons */}
84
+ <div className="w-full max-w-sm space-y-3">
85
+ {/* Primary: Camera */}
86
+ <button
87
+ type="button"
88
+ className="relative flex h-[58px] w-full items-center justify-center gap-3 overflow-hidden rounded-2xl text-base font-bold text-white shadow-xl transition-all duration-150 active:scale-[0.97]"
89
+ style={{
90
+ background: 'linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%)',
91
+ boxShadow: '0 8px 32px rgba(37,99,235,0.45)',
92
+ }}
93
+ onClick={onCamera}
94
+ >
95
+ {/* Shimmer overlay */}
96
+ <span className="pointer-events-none absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent" />
97
+ <Camera size={22} strokeWidth={2.5} />
98
+ {t(lang, 'takePhoto')}
99
+ </button>
100
+
101
+ {/* Secondary: Gallery */}
102
+ <button
103
+ type="button"
104
+ className="flex h-[58px] w-full items-center justify-center gap-3 rounded-2xl border border-white/12 bg-white/6 text-base font-medium text-white/85 backdrop-blur-sm transition-all duration-150 active:scale-[0.97] active:bg-white/10"
105
+ onClick={onGallery}
106
+ >
107
+ <ImagePlus size={22} strokeWidth={2} />
108
+ {t(lang, 'chooseFile')}
109
+ </button>
110
  </div>
111
  </div>
112
 
113
+ {/* Footer */}
114
+ <div className="relative z-10 pb-[max(1.5rem,env(safe-area-inset-bottom))] text-center">
115
+ <p className="text-[11px] tracking-wide text-white/25">{t(lang, 'company')}</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  </div>
 
 
117
  </div>
118
  )
119
  }
frontend/src/components/StepCounting.tsx CHANGED
@@ -18,50 +18,96 @@ export function StepCounting({ lang, status, imageSrc }: Props) {
18
 
19
  return (
20
  <div className="relative flex flex-1 flex-col items-center justify-center overflow-hidden">
21
- {/* blurred image background */}
22
  {imageSrc && (
23
  <img
24
  src={imageSrc}
25
  alt=""
26
  aria-hidden
27
- className="absolute inset-0 h-full w-full object-cover opacity-15 blur-xl scale-110"
28
  />
29
  )}
30
 
31
- <div className="relative z-10 flex flex-col items-center gap-6 px-8 text-center">
32
- {/* pulsing rings */}
33
- <div className="relative h-28 w-28">
34
- <span className="absolute inset-0 animate-[ping_1.4s_cubic-bezier(0,0,0.2,1)_infinite] rounded-full border-2 border-emerald-500/40" />
35
- <span className="absolute inset-3 animate-[ping_1.4s_cubic-bezier(0,0,0.2,1)_infinite_0.4s] rounded-full border-2 border-emerald-500/30" />
36
- <span className="absolute inset-6 animate-[ping_1.4s_cubic-bezier(0,0,0.2,1)_infinite_0.8s] rounded-full border-2 border-emerald-500/20" />
37
- <span className="absolute inset-0 flex items-center justify-center">
38
- <span className="h-14 w-14 rounded-full border-2 border-emerald-500/60 bg-emerald-500/10" />
39
- </span>
40
- <span className="absolute inset-0 flex items-center justify-center">
41
- <img src="/icon.svg" alt="" className="h-10 w-10 opacity-80" />
42
- </span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  </div>
44
 
 
45
  <div>
46
- <h2 className="text-xl font-bold text-white">
47
  {t(lang, 'countingTitle')}{''.padEnd(dots, '.')}
48
  </h2>
49
- <p className="mt-2 min-h-[1.5rem] text-sm text-slate-400">
50
- {status || t(lang, 'countingHint')}
51
  </p>
52
  </div>
53
 
54
- {/* progress bar (indeterminate) */}
55
- <div className="h-1.5 w-56 overflow-hidden rounded-full bg-slate-800">
56
- <div className="h-full w-1/3 animate-[slide_1.5s_ease-in-out_infinite] rounded-full bg-emerald-500" />
 
 
 
57
  </div>
58
  </div>
59
 
60
  <style>{`
 
 
 
61
  @keyframes slide {
62
- 0% { transform: translateX(-100%) }
63
- 50% { transform: translateX(200%) }
64
- 100% { transform: translateX(200%) }
65
  }
66
  `}</style>
67
  </div>
 
18
 
19
  return (
20
  <div className="relative flex flex-1 flex-col items-center justify-center overflow-hidden">
21
+ {/* Blurred background image */}
22
  {imageSrc && (
23
  <img
24
  src={imageSrc}
25
  alt=""
26
  aria-hidden
27
+ className="absolute inset-0 h-full w-full scale-110 object-cover opacity-10 blur-2xl"
28
  />
29
  )}
30
 
31
+ {/* Radial vignette overlay */}
32
+ <div
33
+ className="pointer-events-none absolute inset-0"
34
+ style={{
35
+ background: 'radial-gradient(ellipse 70% 60% at 50% 50%, transparent 20%, #020617 100%)',
36
+ }}
37
+ />
38
+
39
+ <div className="relative z-10 flex flex-col items-center gap-7 px-8 text-center">
40
+ {/* Concentric ring animation */}
41
+ <div className="relative flex h-36 w-36 items-center justify-center">
42
+ {/* Three expanding rings with staggered timing */}
43
+ <span
44
+ className="absolute inset-0 rounded-full border border-emerald-500/30"
45
+ style={{ animation: 'ping 2s cubic-bezier(0,0,0.2,1) infinite' }}
46
+ />
47
+ <span
48
+ className="absolute inset-4 rounded-full border border-emerald-400/25"
49
+ style={{ animation: 'ping 2s cubic-bezier(0,0,0.2,1) 0.5s infinite' }}
50
+ />
51
+ <span
52
+ className="absolute inset-8 rounded-full border border-emerald-300/20"
53
+ style={{ animation: 'ping 2s cubic-bezier(0,0,0.2,1) 1s infinite' }}
54
+ />
55
+
56
+ {/* Static inner circle */}
57
+ <div className="absolute inset-10 rounded-full bg-emerald-500/8 ring-1 ring-emerald-500/40" />
58
+
59
+ {/* Rotating arc */}
60
+ <svg
61
+ className="absolute inset-0 h-full w-full"
62
+ viewBox="0 0 100 100"
63
+ fill="none"
64
+ >
65
+ <circle
66
+ cx="50" cy="50" r="44"
67
+ stroke="rgba(16,185,129,0.15)"
68
+ strokeWidth="2"
69
+ />
70
+ <circle
71
+ cx="50" cy="50" r="44"
72
+ stroke="rgba(16,185,129,0.7)"
73
+ strokeWidth="2"
74
+ strokeLinecap="round"
75
+ strokeDasharray="80 196"
76
+ style={{ animation: 'spin 1.6s linear infinite', transformOrigin: '50% 50%' }}
77
+ />
78
+ </svg>
79
+
80
+ {/* Logo */}
81
+ <img src="/icon.svg" alt="" className="relative z-10 h-10 w-10 opacity-90" />
82
  </div>
83
 
84
+ {/* Text */}
85
  <div>
86
+ <h2 className="text-xl font-semibold tracking-tight text-white">
87
  {t(lang, 'countingTitle')}{''.padEnd(dots, '.')}
88
  </h2>
89
+ <p className="mt-2 min-h-6 text-sm text-white/45">
90
+ {status || t(lang, 'pleaseWait')}
91
  </p>
92
  </div>
93
 
94
+ {/* Progress bar */}
95
+ <div className="h-0.5 w-48 overflow-hidden rounded-full bg-white/10">
96
+ <div
97
+ className="h-full rounded-full bg-emerald-400"
98
+ style={{ animation: 'slide 1.8s ease-in-out infinite', width: '35%' }}
99
+ />
100
  </div>
101
  </div>
102
 
103
  <style>{`
104
+ @keyframes spin {
105
+ to { transform: rotate(360deg); }
106
+ }
107
  @keyframes slide {
108
+ 0% { transform: translateX(-200%); }
109
+ 60% { transform: translateX(380%); }
110
+ 100% { transform: translateX(380%); }
111
  }
112
  `}</style>
113
  </div>
frontend/src/components/StepPreview.tsx CHANGED
@@ -45,25 +45,25 @@ export function StepPreview({
45
  onRecluster,
46
  }: Props) {
47
  const ar = imageDims.h / Math.max(imageDims.w, 1)
48
- // cap preview height at 50vh
49
- const maxPreviewH = Math.min(ar * 100, 50)
50
 
51
  return (
52
  <div className="flex flex-1 flex-col overflow-hidden">
53
- {/* top bar */}
54
- <div className="flex items-center justify-between px-4 py-2">
55
  <button
56
  type="button"
57
- className="flex items-center gap-1 rounded-xl bg-slate-800 px-3 py-2 text-sm font-medium text-slate-200 active:scale-95"
58
  onClick={onBack}
59
  >
60
- <ChevronLeft size={16} />
61
  {t(lang, 'previewBack')}
62
  </button>
 
63
  <div className="flex gap-2">
64
  <button
65
  type="button"
66
- className="flex h-9 w-9 items-center justify-center rounded-xl bg-slate-800 text-slate-300 active:scale-95"
67
  onClick={onRetake}
68
  aria-label={t(lang, 'retake')}
69
  >
@@ -71,7 +71,7 @@ export function StepPreview({
71
  </button>
72
  <button
73
  type="button"
74
- className="flex h-9 w-9 items-center justify-center rounded-xl bg-slate-800 text-slate-300 active:scale-95"
75
  onClick={onGallery}
76
  aria-label={t(lang, 'chooseFile')}
77
  >
@@ -80,25 +80,21 @@ export function StepPreview({
80
  </div>
81
  </div>
82
 
83
- {/* image preview */}
84
  <div
85
- className="mx-4 overflow-hidden rounded-2xl border border-slate-700/60 bg-black shadow-md"
86
  style={{ height: `${maxPreviewH}vh` }}
87
  >
88
- <img
89
- src={imageSrc}
90
- alt="Preview"
91
- className="h-full w-full object-contain"
92
- />
93
  </div>
94
 
95
- {/* image info */}
96
- <p className="mt-1.5 px-4 text-xs text-slate-500">
97
- {imageDims.w} Γ— {imageDims.h} px
98
  </p>
99
 
100
- {/* scrollable settings */}
101
- <div className="flex-1 overflow-y-auto px-4 pb-2 pt-3">
102
  <SettingsPanel
103
  lang={lang}
104
  open={true}
@@ -114,14 +110,25 @@ export function StepPreview({
114
  />
115
  </div>
116
 
117
- {/* sticky count button */}
118
- <div className="border-t border-slate-800/80 px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-3">
 
 
 
 
 
 
119
  <button
120
  type="button"
121
  disabled={busy || !modelReady}
122
- className="flex h-14 w-full items-center justify-center gap-3 rounded-2xl bg-emerald-600 text-base font-bold text-white shadow-lg shadow-emerald-900/40 active:scale-[0.98] disabled:opacity-50"
 
 
 
 
123
  onClick={onCount}
124
  >
 
125
  {busy ? <Loader2 className="animate-spin" size={22} /> : null}
126
  {t(lang, 'countNow')}
127
  </button>
 
45
  onRecluster,
46
  }: Props) {
47
  const ar = imageDims.h / Math.max(imageDims.w, 1)
48
+ const maxPreviewH = Math.min(ar * 100, 52)
 
49
 
50
  return (
51
  <div className="flex flex-1 flex-col overflow-hidden">
52
+ {/* ── Navigation bar ─────────────────────────────────────────── */}
53
+ <div className="flex items-center justify-between px-4 py-2.5">
54
  <button
55
  type="button"
56
+ className="flex h-9 items-center gap-1 rounded-xl bg-white/7 px-3 text-sm font-medium text-white/85 transition-all duration-150 active:scale-95 active:bg-white/12"
57
  onClick={onBack}
58
  >
59
+ <ChevronLeft size={16} strokeWidth={2.5} />
60
  {t(lang, 'previewBack')}
61
  </button>
62
+
63
  <div className="flex gap-2">
64
  <button
65
  type="button"
66
+ className="flex h-9 w-9 items-center justify-center rounded-xl bg-white/7 text-white/70 transition-all duration-150 active:scale-95 active:bg-white/12"
67
  onClick={onRetake}
68
  aria-label={t(lang, 'retake')}
69
  >
 
71
  </button>
72
  <button
73
  type="button"
74
+ className="flex h-9 w-9 items-center justify-center rounded-xl bg-white/7 text-white/70 transition-all duration-150 active:scale-95 active:bg-white/12"
75
  onClick={onGallery}
76
  aria-label={t(lang, 'chooseFile')}
77
  >
 
80
  </div>
81
  </div>
82
 
83
+ {/* ── Image preview ──────────────────────────────────────────── */}
84
  <div
85
+ className="mx-4 overflow-hidden rounded-2xl bg-black shadow-xl ring-1 ring-white/8"
86
  style={{ height: `${maxPreviewH}vh` }}
87
  >
88
+ <img src={imageSrc} alt="Preview" className="h-full w-full object-contain" />
 
 
 
 
89
  </div>
90
 
91
+ {/* Image dimension tag */}
92
+ <p className="mt-1.5 px-5 text-[11px] text-white/30 tabular-nums">
93
+ {imageDims.w} Γ— {imageDims.h}
94
  </p>
95
 
96
+ {/* ── Scrollable settings ────────────────────────────────────── */}
97
+ <div className="flex-1 overflow-y-auto px-4 pb-2 pt-2">
98
  <SettingsPanel
99
  lang={lang}
100
  open={true}
 
110
  />
111
  </div>
112
 
113
+ {/* ── Sticky CTA ─────────────────────────────────────────────── */}
114
+ <div
115
+ className="shrink-0 px-4 pt-3"
116
+ style={{ paddingBottom: 'max(1rem, env(safe-area-inset-bottom))' }}
117
+ >
118
+ {/* Separator */}
119
+ <div className="mb-3 h-px bg-gradient-to-r from-transparent via-white/10 to-transparent" />
120
+
121
  <button
122
  type="button"
123
  disabled={busy || !modelReady}
124
+ className="relative flex h-[58px] w-full items-center justify-center gap-3 overflow-hidden rounded-2xl text-base font-bold text-white shadow-xl transition-all duration-150 active:scale-[0.98] disabled:opacity-50"
125
+ style={{
126
+ background: 'linear-gradient(135deg, #059669 0%, #047857 60%, #065f46 100%)',
127
+ boxShadow: '0 8px 28px rgba(5,150,105,0.4)',
128
+ }}
129
  onClick={onCount}
130
  >
131
+ <span className="pointer-events-none absolute inset-0 bg-gradient-to-r from-transparent via-white/8 to-transparent" />
132
  {busy ? <Loader2 className="animate-spin" size={22} /> : null}
133
  {t(lang, 'countNow')}
134
  </button>
frontend/src/components/StepResults.tsx CHANGED
@@ -1,5 +1,5 @@
1
  import { useRef, useState } from 'react'
2
- import { Download, Plus, RotateCcw } from 'lucide-react'
3
  import { t } from '../lib/i18n'
4
  import type { Detection, DiameterGroup, Lang, ToolMode } from '../lib/types'
5
  import { ResultCanvas } from './ResultCanvas'
@@ -40,32 +40,36 @@ export function StepResults({
40
 
41
  return (
42
  <div className="flex flex-1 flex-col overflow-hidden">
43
- {/* top bar */}
44
- <div className="flex items-center justify-between px-4 py-2">
 
45
  <button
46
  type="button"
47
- className="flex h-9 items-center gap-1.5 rounded-xl bg-slate-800 px-3 text-sm font-medium text-slate-200 active:scale-95"
48
  onClick={onNewPhoto}
49
  >
50
- <Plus size={15} className="rotate-45" />
51
  {t(lang, 'resultsBack')}
52
  </button>
53
 
54
- {/* live count hero */}
55
  <div className="flex flex-col items-center">
56
  <span
57
  ref={countDisplayRef}
58
- className="text-3xl font-bold tabular-nums leading-none text-white"
59
  >
60
  {detections.length}
61
  </span>
62
- <span className="text-[10px] uppercase tracking-widest text-slate-500">{t(lang, 'total')}</span>
 
 
63
  </div>
64
 
 
65
  <div className="flex gap-2">
66
  <button
67
  type="button"
68
- className="flex h-9 w-9 items-center justify-center rounded-xl bg-slate-800 text-slate-300 active:scale-95"
69
  onClick={() => setExportOpen(true)}
70
  aria-label={t(lang, 'export')}
71
  >
@@ -73,7 +77,7 @@ export function StepResults({
73
  </button>
74
  <button
75
  type="button"
76
- className="flex h-9 w-9 items-center justify-center rounded-xl bg-emerald-700 text-white active:scale-95"
77
  onClick={onRecount}
78
  aria-label={t(lang, 'recount')}
79
  >
@@ -82,25 +86,28 @@ export function StepResults({
82
  </div>
83
  </div>
84
 
85
- {/* scrollable body */}
86
- <div className="flex-1 overflow-y-auto px-4 pb-[max(1.5rem,env(safe-area-inset-bottom))]">
 
 
 
87
  <div className="space-y-4">
88
- {/* group summary chips – quick overview */}
89
  {groups.length > 1 && (
90
  <div className="flex flex-wrap gap-2">
91
  {groups.map((g) => (
92
  <span
93
  key={g.id}
94
- className="inline-flex items-center gap-1.5 rounded-full bg-slate-800/80 px-3 py-1 text-sm font-medium text-slate-200 ring-1 ring-slate-700"
95
  >
96
- <span className="h-2.5 w-2.5 rounded-full" style={{ background: g.color }} />
97
  {g.label}: {counts[g.id] ?? 0}
98
  </span>
99
  ))}
100
  </div>
101
  )}
102
 
103
- {/* canvas with animation */}
104
  <ResultCanvas
105
  image={image}
106
  detections={detections}
@@ -113,19 +120,24 @@ export function StepResults({
113
  countDisplayRef={countDisplayRef}
114
  />
115
 
116
- {/* correction tools (appear after animation) */}
117
  {animDone && (
118
- <>
119
- <GroupPanel
120
- lang={lang}
121
- groups={groups}
122
- counts={counts}
123
- selectedGroupId={selectedGroupId}
124
- onSelectGroup={setSelectedGroupId}
125
- onExpectedChange={onExpectedChange}
126
- />
 
 
 
 
 
127
  <ToolBar lang={lang} tool={tool} onToolChange={setTool} />
128
- </>
129
  )}
130
  </div>
131
  </div>
 
1
  import { useRef, useState } from 'react'
2
+ import { Camera, Download, RotateCcw } from 'lucide-react'
3
  import { t } from '../lib/i18n'
4
  import type { Detection, DiameterGroup, Lang, ToolMode } from '../lib/types'
5
  import { ResultCanvas } from './ResultCanvas'
 
40
 
41
  return (
42
  <div className="flex flex-1 flex-col overflow-hidden">
43
+ {/* ── Top bar ──────────────────────────────────────────────── */}
44
+ <div className="flex shrink-0 items-center justify-between px-4 py-2">
45
+ {/* New photo */}
46
  <button
47
  type="button"
48
+ className="flex h-9 items-center gap-1.5 rounded-xl bg-white/7 px-3 text-sm font-medium text-white/70 transition-all duration-150 active:scale-95 active:bg-white/12"
49
  onClick={onNewPhoto}
50
  >
51
+ <Camera size={15} />
52
  {t(lang, 'resultsBack')}
53
  </button>
54
 
55
+ {/* Live count */}
56
  <div className="flex flex-col items-center">
57
  <span
58
  ref={countDisplayRef}
59
+ className="text-[34px] font-bold tabular-nums leading-none text-white"
60
  >
61
  {detections.length}
62
  </span>
63
+ <span className="mt-0.5 text-[10px] uppercase tracking-widest text-white/35">
64
+ {t(lang, 'total')}
65
+ </span>
66
  </div>
67
 
68
+ {/* Actions */}
69
  <div className="flex gap-2">
70
  <button
71
  type="button"
72
+ className="flex h-9 w-9 items-center justify-center rounded-xl bg-white/7 text-white/70 transition-all duration-150 active:scale-95 active:bg-white/12"
73
  onClick={() => setExportOpen(true)}
74
  aria-label={t(lang, 'export')}
75
  >
 
77
  </button>
78
  <button
79
  type="button"
80
+ className="flex h-9 w-9 items-center justify-center rounded-xl bg-emerald-600/80 text-white transition-all duration-150 active:scale-95 active:bg-emerald-500"
81
  onClick={onRecount}
82
  aria-label={t(lang, 'recount')}
83
  >
 
86
  </div>
87
  </div>
88
 
89
+ {/* ── Scrollable body ────────────────────────────────────────── */}
90
+ <div
91
+ className="flex-1 overflow-y-auto px-4"
92
+ style={{ paddingBottom: 'max(1.5rem, env(safe-area-inset-bottom))' }}
93
+ >
94
  <div className="space-y-4">
95
+ {/* Group summary chips */}
96
  {groups.length > 1 && (
97
  <div className="flex flex-wrap gap-2">
98
  {groups.map((g) => (
99
  <span
100
  key={g.id}
101
+ className="inline-flex items-center gap-1.5 rounded-full bg-white/7 px-3 py-1 text-sm font-medium text-white/80 ring-1 ring-white/10"
102
  >
103
+ <span className="h-2 w-2 rounded-full" style={{ background: g.color }} />
104
  {g.label}: {counts[g.id] ?? 0}
105
  </span>
106
  ))}
107
  </div>
108
  )}
109
 
110
+ {/* Detection canvas */}
111
  <ResultCanvas
112
  image={image}
113
  detections={detections}
 
120
  countDisplayRef={countDisplayRef}
121
  />
122
 
123
+ {/* Correction tools β€” slide in after animation */}
124
  {animDone && (
125
+ <div
126
+ className="space-y-4"
127
+ style={{ animation: 'step-enter 0.35s cubic-bezier(0.22,1,0.36,1) both' }}
128
+ >
129
+ {groups.length > 0 && (
130
+ <GroupPanel
131
+ lang={lang}
132
+ groups={groups}
133
+ counts={counts}
134
+ selectedGroupId={selectedGroupId}
135
+ onSelectGroup={setSelectedGroupId}
136
+ onExpectedChange={onExpectedChange}
137
+ />
138
+ )}
139
  <ToolBar lang={lang} tool={tool} onToolChange={setTool} />
140
+ </div>
141
  )}
142
  </div>
143
  </div>
frontend/src/components/ToolBar.tsx CHANGED
@@ -3,12 +3,17 @@ import { cn } from '../lib/utils'
3
  import { t } from '../lib/i18n'
4
  import type { Lang, ToolMode } from '../lib/types'
5
 
6
- const TOOLS: { id: ToolMode; icon: typeof Eye; labelKey: 'toolView' | 'toolDelete' | 'toolAdd' | 'toolReassign' | 'toolArea' }[] = [
7
- { id: 'view', icon: Eye, labelKey: 'toolView' },
8
- { id: 'delete', icon: Trash2, labelKey: 'toolDelete' },
9
- { id: 'add', icon: Plus, labelKey: 'toolAdd' },
10
- { id: 'reassign', icon: Tag, labelKey: 'toolReassign' },
11
- { id: 'area', icon: SquareDashed, labelKey: 'toolArea' },
 
 
 
 
 
12
  ]
13
 
14
  interface Props {
@@ -20,25 +25,35 @@ interface Props {
20
  export function ToolBar({ lang, tool, onToolChange }: Props) {
21
  return (
22
  <section>
23
- <p className="mb-2 text-xs font-medium uppercase tracking-wide text-slate-500">{t(lang, 'tools')}</p>
24
- <div className="flex gap-2 overflow-x-auto pb-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
25
- {TOOLS.map(({ id, icon: Icon, labelKey }) => {
26
- const active = tool === id
27
- return (
28
- <button
29
- key={id}
30
- type="button"
31
- className={cn(
32
- 'flex min-h-11 shrink-0 items-center gap-2 rounded-xl px-4 text-sm font-medium transition active:scale-95',
33
- active ? 'bg-white text-slate-900 shadow-lg' : 'bg-slate-800 text-slate-300',
34
- )}
35
- onClick={() => onToolChange(id)}
36
- >
37
- <Icon size={16} />
38
- {t(lang, labelKey)}
39
- </button>
40
- )
41
- })}
 
 
 
 
 
 
 
 
 
 
42
  </div>
43
  </section>
44
  )
 
3
  import { t } from '../lib/i18n'
4
  import type { Lang, ToolMode } from '../lib/types'
5
 
6
+ const TOOLS: {
7
+ id: ToolMode
8
+ icon: typeof Eye
9
+ labelKey: 'toolView' | 'toolDelete' | 'toolAdd' | 'toolReassign' | 'toolArea'
10
+ activeColor: string
11
+ }[] = [
12
+ { id: 'view', icon: Eye, labelKey: 'toolView', activeColor: 'bg-white text-slate-900' },
13
+ { id: 'delete', icon: Trash2, labelKey: 'toolDelete', activeColor: 'bg-red-500 text-white' },
14
+ { id: 'add', icon: Plus, labelKey: 'toolAdd', activeColor: 'bg-emerald-500 text-white' },
15
+ { id: 'reassign', icon: Tag, labelKey: 'toolReassign', activeColor: 'bg-blue-500 text-white' },
16
+ { id: 'area', icon: SquareDashed, labelKey: 'toolArea', activeColor: 'bg-violet-500 text-white' },
17
  ]
18
 
19
  interface Props {
 
25
  export function ToolBar({ lang, tool, onToolChange }: Props) {
26
  return (
27
  <section>
28
+ <p className="mb-2 px-1 text-[11px] font-medium uppercase tracking-widest text-white/30">
29
+ {t(lang, 'tools')}
30
+ </p>
31
+
32
+ {/* Floating pill container */}
33
+ <div className="overflow-hidden rounded-2xl bg-white/6 p-1.5 ring-1 ring-white/8">
34
+ <div className="flex gap-1 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
35
+ {TOOLS.map(({ id, icon: Icon, labelKey, activeColor }) => {
36
+ const active = tool === id
37
+ return (
38
+ <button
39
+ key={id}
40
+ type="button"
41
+ className={cn(
42
+ 'flex shrink-0 items-center gap-1.5 rounded-xl px-3.5 py-2 text-sm font-semibold transition-all duration-200 active:scale-[0.96]',
43
+ active
44
+ ? `${activeColor} shadow-sm`
45
+ : 'text-white/55 hover:text-white/80 active:bg-white/10',
46
+ )}
47
+ onClick={() => onToolChange(id)}
48
+ >
49
+ <Icon size={15} strokeWidth={active ? 2.5 : 2} />
50
+ <span className={active ? 'opacity-100' : 'opacity-70'}>
51
+ {t(lang, labelKey)}
52
+ </span>
53
+ </button>
54
+ )
55
+ })}
56
+ </div>
57
  </div>
58
  </section>
59
  )
frontend/src/index.css CHANGED
@@ -1,7 +1,9 @@
1
  @import 'tailwindcss';
2
 
3
  :root {
4
- font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
 
 
5
  color: #f8fafc;
6
  background: #020617;
7
  -webkit-tap-highlight-color: transparent;
@@ -15,7 +17,7 @@ html {
15
  body {
16
  margin: 0;
17
  min-height: 100dvh;
18
- background: radial-gradient(ellipse 120% 80% at 50% -20%, #1e3a5f 0%, #020617 55%);
19
  }
20
 
21
  #root {
@@ -24,6 +26,7 @@ body {
24
 
25
  button {
26
  touch-action: manipulation;
 
27
  }
28
 
29
  button:disabled {
@@ -40,3 +43,38 @@ input[type='number']::-webkit-inner-spin-button {
40
  -webkit-appearance: none;
41
  margin: 0;
42
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  @import 'tailwindcss';
2
 
3
  :root {
4
+ /* Platform-native font stack: SF Pro on iOS/macOS, Roboto on Android, Segoe UI on Windows */
5
+ font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue',
6
+ system-ui, 'Segoe UI', Roboto, sans-serif;
7
  color: #f8fafc;
8
  background: #020617;
9
  -webkit-tap-highlight-color: transparent;
 
17
  body {
18
  margin: 0;
19
  min-height: 100dvh;
20
+ background: #020617;
21
  }
22
 
23
  #root {
 
26
 
27
  button {
28
  touch-action: manipulation;
29
+ -webkit-tap-highlight-color: transparent;
30
  }
31
 
32
  button:disabled {
 
43
  -webkit-appearance: none;
44
  margin: 0;
45
  }
46
+
47
+ /* ─── Page-level step transition ─────────────────────────────── */
48
+ @keyframes step-enter {
49
+ from { opacity: 0; transform: translateY(18px); }
50
+ to { opacity: 1; transform: translateY(0); }
51
+ }
52
+
53
+ /* ─── Bottom-sheet entrance ──────────────────────────────────── */
54
+ @keyframes sheet-up {
55
+ from { transform: translateY(100%); }
56
+ to { transform: translateY(0); }
57
+ }
58
+
59
+ /* ─── Overlay fade ───────────────────────────────────────────── */
60
+ @keyframes fade-in {
61
+ from { opacity: 0; }
62
+ to { opacity: 1; }
63
+ }
64
+
65
+ /* ─── Logo breathing ─────────────────────────────────────────── */
66
+ @keyframes breathe {
67
+ 0%, 100% { transform: scale(1); }
68
+ 50% { transform: scale(1.035); }
69
+ }
70
+
71
+ /* ─── Glow pulse ─────────────────────────────────────────────── */
72
+ @keyframes glow-pulse {
73
+ 0%, 100% { opacity: 0.35; transform: scale(1); }
74
+ 50% { opacity: 0.55; transform: scale(1.08); }
75
+ }
76
+
77
+ /* ─── Slide-in animation utility ─────────────────────────────── */
78
+ .step-enter { animation: step-enter 0.32s cubic-bezier(0.22, 1, 0.36, 1) both; }
79
+ .sheet-enter { animation: sheet-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) both; }
80
+ .overlay-enter { animation: fade-in 0.2s ease-out both; }