:root {
  --ink: #05080d;
  --cyan: #29d3ff;
  --blue: #2b7cff;
  --green: #3ddc97;
  --amber: #ffcb47;
  --pink: #ff5470;
  font-family: 'Bricolage Grotesque', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #02040a;
  overflow: hidden;
  font-family: 'Bricolage Grotesque', sans-serif;
  color: #eaf6ff;
}
#root { height: 100vh; }

.app-root {
  position: relative;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: radial-gradient(120% 80% at 50% 0%, #0a1524 0%, #02040a 70%);
  box-shadow: 0 0 60px rgba(41,211,255,.12);
  overflow: hidden;
}

/* ---- camera stage ---- */
.stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #000;
  display: flex; align-items: center; justify-content: center;
}
.video-feed {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.cam-error {
  text-align: center; padding: 24px;
  display: flex; flex-direction: column; align-items: center;
}

/* top bar */
.top-bar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  z-index: 6;
  background: linear-gradient(180deg, rgba(2,6,14,.75), transparent);
  backdrop-filter: blur(4px);
}
.brand {
  font-weight: 300; font-size: 17px; letter-spacing: -.02em;
  display: flex; align-items: baseline; gap: 4px;
}
.brand .pro {
  font-weight: 800;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gear {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: #cdeeff; font-size: 12px; font-weight: 700;
  padding: 6px 11px; border-radius: 999px; cursor: pointer;
}

/* guide frame */
.guide-wrap {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 4; pointer-events: none;
}
.guide-frame {
  position: relative;
  width: 70%; height: 18%;
  border-radius: 14px;
  transition: box-shadow .25s;
}
.guide-frame.seek { box-shadow: 0 0 0 9999px rgba(2,6,14,.42), 0 0 24px rgba(255,203,71,.3); }
.guide-frame.ok   { box-shadow: 0 0 0 9999px rgba(2,6,14,.42), 0 0 30px rgba(61,220,151,.5); }
.corner {
  position: absolute; width: 22px; height: 22px;
  border: 3px solid var(--amber);
  transition: border-color .25s;
}
.guide-frame.ok .corner { border-color: var(--green); }
.corner.tl { top: -2px; left: -2px; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.corner.tr { top: -2px; right: -2px; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.corner.bl { bottom: -2px; left: -2px; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.corner.br { bottom: -2px; right: -2px; border-left: none; border-top: none; border-radius: 0 0 8px 0; }
.scan-line {
  position: absolute; left: 6%; right: 6%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 12px var(--cyan);
  animation: scan 2.4s ease-in-out infinite;
}
@keyframes scan { 0%,100% { top: 12%; } 50% { top: 84%; } }
.detect-chip {
  margin-top: 18px;
  font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px;
  backdrop-filter: blur(6px);
  transition: all .25s;
}
.detect-chip.seek { background: rgba(255,203,71,.15); color: var(--amber); border: 1px solid rgba(255,203,71,.4); }
.detect-chip.ok   { background: rgba(61,220,151,.18); color: var(--green); border: 1px solid rgba(61,220,151,.5); }

/* clarity meter */
.clarity-wrap {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.clarity-track {
  width: 10px; height: 150px;
  background: rgba(255,255,255,.1);
  border-radius: 999px; overflow: hidden;
  display: flex; align-items: flex-end;
  border: 1px solid rgba(255,255,255,.15);
}
.clarity-fill { width: 100%; border-radius: 999px; transition: height .18s, background .25s; }
.clarity-label {
  writing-mode: vertical-rl;
  font-size: 10.5px; font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  text-shadow: 0 1px 4px rgba(0,0,0,.7);
}

/* flash */
.flash-overlay {
  position: absolute; inset: 0; z-index: 20;
  background: #fff;
  animation: flashfade .28s ease-out forwards;
}
@keyframes flashfade { 0% { opacity: 1; } 100% { opacity: 0; } }

/* controls */
.controls {
  position: relative; z-index: 7;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 34px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, #02040a 40%, rgba(2,6,14,.6));
}
.torch, .history-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  color: #eaf6ff; font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: all .2s;
}
.torch:disabled { opacity: .3; }
.torch.on { background: rgba(255,203,71,.25); border-color: var(--amber); box-shadow: 0 0 20px rgba(255,203,71,.5); }
.history-btn { overflow: visible; }
.hist-thumb { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.hist-count {
  position: absolute; top: -4px; right: -4px;
  background: var(--cyan); color: #02040a;
  font-size: 11px; font-weight: 800; font-family: 'JetBrains Mono', monospace;
  min-width: 20px; height: 20px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.shutter {
  width: 78px; height: 78px; border-radius: 50%;
  border: none; background: transparent; cursor: pointer;
  position: relative; padding: 0;
  transition: transform .2s;
}
.shutter.ready { transform: scale(1.06); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1.06); } 50% { transform: scale(1.12); } }
.shutter-ring {
  position: absolute; inset: 0; border-radius: 50%; padding: 5px;
}
.shutter-core {
  position: absolute; inset: 8px; border-radius: 50%;
  background: linear-gradient(135deg, #eaf6ff, #b7e6ff);
  box-shadow: inset 0 0 0 3px #02040a;
}
.shutter:active .shutter-core { background: var(--cyan); }

/* modals */
.modal-back {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(2,4,10,.8); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: fadein .2s;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 400px;
  background: linear-gradient(160deg, #0d1a2c, #071019);
  border: 1px solid rgba(41,211,255,.2);
  border-radius: 22px; padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  animation: pop .3s cubic-bezier(.2,1.2,.4,1);
}
@keyframes pop { from { transform: scale(.9) translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 20px; font-weight: 700; margin: 0 0 14px; letter-spacing: -.02em; }
.modal-img { width: 100%; border-radius: 12px; margin-bottom: 12px; border: 1px solid rgba(255,255,255,.12); }
.ocr-status { display: flex; align-items: center; gap: 8px; color: var(--cyan); font-size: 14px; margin-bottom: 10px; }
.ocr-hint { color: rgba(202,238,255,.6); font-size: 13px; margin-bottom: 10px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(41,211,255,.3); border-top-color: var(--cyan);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.odometer { display: flex; gap: 10px; margin-bottom: 8px; }
.odo-input {
  flex: 1; font-family: 'JetBrains Mono', monospace; font-weight: 800;
  font-size: 30px; letter-spacing: 4px; text-align: center;
  background: #01060c; color: var(--green);
  border: 2px solid rgba(61,220,151,.4); border-radius: 12px;
  padding: 12px 8px; outline: none;
  box-shadow: inset 0 2px 12px rgba(0,0,0,.6);
}
.odo-input::placeholder { color: rgba(61,220,151,.25); }
.unit-tag {
  background: rgba(41,211,255,.15); border: 1px solid rgba(41,211,255,.4);
  color: var(--cyan); font-weight: 700; font-family: 'JetBrains Mono', monospace;
  border-radius: 12px; padding: 0 16px; cursor: pointer; font-size: 15px;
}
.delta-note { font-size: 13px; color: rgba(202,238,255,.7); margin: 8px 0 14px; font-weight: 600; }
.delta-note.warn { color: var(--amber); background: rgba(255,203,71,.1); border: 1px solid rgba(255,203,71,.3); padding: 8px 12px; border-radius: 10px; }
.modal-actions { display: flex; gap: 10px; }
.btn {
  flex: 1; padding: 13px; border-radius: 12px; font-weight: 700; font-size: 15px;
  cursor: pointer; border: none; transition: all .15s; font-family: inherit;
}
.btn.primary { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #02040a; }
.btn.primary:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary:not(:disabled):active { transform: scale(.97); }
.btn.ghost { background: rgba(255,255,255,.08); color: #cdeeff; border: 1px solid rgba(255,255,255,.15); }
.btn.wide { width: 100%; flex: none; margin-top: 8px; }
.btn.tiny { flex: none; padding: 8px 14px; font-size: 13px; background: rgba(255,255,255,.08); color: #cdeeff; border: 1px solid rgba(255,255,255,.15); }
.btn.tiny:disabled { opacity: .4; }

.upload-btn {
  background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #02040a;
  font-weight: 700; padding: 12px 22px; border-radius: 12px; cursor: pointer;
}

/* drawer / history */
.drawer {
  width: 100%; max-width: 440px;
  max-height: 88vh; overflow-y: auto;
  background: linear-gradient(160deg, #0d1a2c, #071019);
  border: 1px solid rgba(41,211,255,.2);
  border-radius: 22px; padding: 20px;
  animation: pop .3s cubic-bezier(.2,1.2,.4,1);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.close-x { background: none; border: none; color: #cdeeff; font-size: 20px; cursor: pointer; }
.spark-wrap { margin: 14px 0; padding: 14px; background: rgba(1,6,12,.6); border-radius: 14px; border: 1px solid rgba(255,255,255,.08); }
.spark-title { font-size: 12px; color: rgba(202,238,255,.55); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .08em; }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 60px; }
.spark-bar { flex: 1; background: linear-gradient(180deg, var(--cyan), var(--blue)); border-radius: 4px 4px 0 0; min-height: 4px; }
.hist-tools { display: flex; gap: 8px; margin-bottom: 14px; }
.hist-list { display: flex; flex-direction: column; gap: 10px; }
.empty { color: rgba(202,238,255,.5); text-align: center; padding: 30px 0; font-style: italic; }
.hist-item {
  display: flex; gap: 12px; align-items: center;
  background: rgba(1,6,12,.5); border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px; padding: 10px;
}
.hist-item-img { width: 64px; height: 40px; object-fit: cover; border-radius: 8px; }
.hist-item-body { flex: 1; }
.hist-val { font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: 20px; color: var(--green); }
.hist-unit { font-size: 12px; color: var(--cyan); font-weight: 700; }
.hist-time { font-size: 11px; color: rgba(202,238,255,.45); }
.hist-delta { font-size: 12px; color: var(--cyan); font-weight: 700; margin-top: 2px; }
.hist-delta.neg { color: var(--pink); }
.del { background: none; border: none; font-size: 16px; cursor: pointer; opacity: .5; }
.del:hover { opacity: 1; }

/* onboarding */
.onboard { text-align: center; }
.onboard-list { text-align: left; list-style: none; padding: 0; margin: 8px 0 14px; }
.onboard-list li { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.07); font-size: 14px; color: #dbf1ff; }
.onboard-tip { font-size: 13px; color: var(--amber); margin: 4px 0 8px; }

.footer { text-align: center; margin-top: 16px; font-size: 12px; }
.footer a { color: var(--cyan); text-decoration: none; opacity: .7; }
.footer a:hover { opacity: 1; text-decoration: underline; }

.hidden { display: none; }
</parameter>