/* =========================================================================
   MedDex Lens — standalone premium AI camera experience (v2 redesign)
   Full-screen camera · floating controls · Apple-Maps bottom sheet ·
   on-image AI scan animation · floating Baihaqi assistant.
   Loaded AFTER styles.css so it wins the cascade for the Lens screen only.
   ========================================================================= */

:root {
  --lens-accent: #64d2ff;
  --lens-accent-2: #0a84ff;
  --lens-danger: #ff6b6b;
  --lens-glass: rgba(18, 21, 28, 0.52);
  --lens-glass-strong: rgba(16, 19, 26, 0.72);
  --lens-hairline: rgba(255, 255, 255, 0.14);
  --lens-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --lens-safe-top: env(safe-area-inset-top, 0px);
  --lens-safe-bottom: env(safe-area-inset-bottom, 0px);
}

.lens-usage-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(18, 21, 28, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.9);
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.lens-usage-badge strong {
  color: var(--lens-accent, #64d2ff);
  font-weight: 700;
}
.lens-usage-pro {
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

/* ---- Lens credits ------------------------------------------------------- */
/* The chip stacks the wallet (total), its split (monthly vs purchased) and the
   reset date, so a student can answer "how many do I have and when do more
   arrive?" without opening anything. */
.lens-credit-chip {
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 7px 13px;
  line-height: 1.35;
}
.lens-credit-chip-main {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 0.78rem;
}
.lens-credit-chip-main strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--lens-accent, #64d2ff);
}
.lens-credit-chip-split,
.lens-credit-chip-reset {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.015em;
  color: rgba(255, 255, 255, 0.62);
}
.lens-credit-chip.is-low .lens-credit-chip-main strong { color: #ffcf70; }
.lens-credit-chip.is-empty .lens-credit-chip-main strong { color: var(--lens-danger, #ff6b6b); }
.lens-credit-chip.is-empty { border-color: rgba(255, 107, 107, 0.42); }

/* The pre-analysis line. Deliberately quiet: it states the cost, it does not
   nag, and it only sharpens when the balance is genuinely low. */
.lens-credit-notice {
  position: relative;
  z-index: 4;
  margin: 0 auto 10px;
  width: fit-content;
  max-width: min(90vw, 420px);
  padding: 6px 14px;
  border-radius: 9999px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(18, 21, 28, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: none;
}
.lens-credit-notice[hidden] { display: none; }
.lens-credit-notice.is-low {
  color: #ffd79a;
  border-color: rgba(255, 193, 92, 0.4);
  background: rgba(60, 42, 12, 0.55);
}
.lens-credit-notice.is-empty {
  color: #ffb4b4;
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(64, 20, 24, 0.6);
}

/* ---- Top-up packs ------------------------------------------------------- */
.lens-topup { margin-top: 18px; }
.lens-topup-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}
.lens-topup-sub {
  margin: 0 0 14px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.62);
}
.lens-pack-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
/* One column on a phone: three price cards side by side stop being tappable
   below roughly 420px. */
@media (max-width: 460px) {
  .lens-pack-grid { grid-template-columns: 1fr; }
}
.lens-pack-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 18px 12px 14px;
  border-radius: 18px;
  cursor: pointer;
  font: inherit;
  color: #ffffff;
  text-align: center;
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.28);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 180ms var(--lens-ease), background 180ms var(--lens-ease),
              border-color 180ms var(--lens-ease), box-shadow 180ms var(--lens-ease);
}
.lens-pack-card:hover {
  background: rgba(34, 211, 238, 0.18);
  border-color: rgba(56, 189, 248, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(34, 211, 238, 0.24);
}
.lens-pack-card:active { transform: scale(0.98); }
.lens-pack-card:focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; }
.lens-pack-card:disabled { opacity: 0.6; cursor: progress; }
.lens-pack-badge {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 9px;
  border-radius: 9999px;
  white-space: nowrap;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #04222b;
  background: linear-gradient(135deg, #7dd3fc, #38bdf8);
}
.lens-pack-credits { font-size: 1.7rem; font-weight: 700; line-height: 1; color: #38bdf8; }
.lens-pack-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}
.lens-pack-price { margin-top: 6px; font-size: 0.95rem; font-weight: 700; }
.lens-pack-title { font-size: 0.66rem; color: rgba(255, 255, 255, 0.55); }

.lens-upgrade-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  margin-top: 12px;
  padding: 16px 18px;
  border-radius: 18px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: #ffffff;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.14), rgba(255, 170, 0, 0.08));
  border: 1px solid rgba(255, 200, 60, 0.4);
  transition: transform 180ms var(--lens-ease), box-shadow 180ms var(--lens-ease);
}
.lens-upgrade-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(255, 190, 60, 0.22);
}
.lens-upgrade-card:focus-visible { outline: 2px solid #ffc85a; outline-offset: 3px; }
.lens-upgrade-eyebrow {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #ffd166;
}
.lens-upgrade-title { font-size: 1rem; font-weight: 700; }
.lens-upgrade-sub { font-size: 0.78rem; color: rgba(255, 255, 255, 0.66); }

/* ---- Immersive shell ---------------------------------------------------- */
.lens-screen.lens-v2 {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  max-width: none;
  width: 100%;
  height: 100%;
  height: 100dvh;
  /* Maps-style report sheet: three snap stops as translateY of a 90dvh panel.
     Visible height = 90dvh - offset → collapsed 24dvh, medium 55dvh, full 90dvh.
     --lens-peek (the collapsed visible height) reserves space so the image is never
     covered by default and stays the primary canvas. */
  --lens-sheet-panel-h: 90dvh;
  --lens-snap-collapsed: 66dvh;
  --lens-snap-medium: 35dvh;
  --lens-snap-full: 0dvh;
  --lens-peek: calc(24dvh + var(--lens-safe-bottom));
  background: #000;
  color: #fff;
  overflow: hidden;
  z-index: 2400;
  animation: none !important;
  transform: none !important;
  -webkit-tap-highlight-color: transparent;
}
.lens-screen.lens-v2:not(.active) { display: none; }

/* Hide app chrome while Lens is open — true full screen. */
body.lens-immersive .bottom-nav,
body.lens-immersive .ai-companion-container,
body.lens-immersive #aiCompanionContainer,
body.lens-immersive .app-header,
body.lens-immersive header.topbar,
body.lens-immersive .topbar,
body.lens-immersive .top-bar { display: none !important; }

.lens-v2 .lens-bg { display: none; }

/* The legacy full-screen progress modal is replaced by the on-image scan overlay;
   its JS still runs (and now drives the scan label), but the card stays hidden. */
body.lens-immersive .lens-progress-modal { display: none !important; }

/* ---- Camera / image stage ---------------------------------------------- */
.lens-v2 .lens-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 12%, #10151f 0%, #05070c 70%, #000 100%);
}
.lens-v2 .lens-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Digital viewfinder zoom scales about the centre, which is the same point the
     capture crops about. `transform` is deliberately NOT transitioned so a pinch
     tracks the fingers 1:1. */
  transform-origin: 50% 50%;
  transition: opacity 0.4s var(--lens-ease), filter 0.6s var(--lens-ease);
}
.lens-v2.lens-has-image .lens-video { opacity: 0; filter: blur(6px); }

/* The analysed still: shrink-wrapped box so overlay % coords stay aligned.
   The bottom inset reserves the collapsed-sheet height so the image (and its overlay /
   heatmap / labels) sits fully above the sheet by default and remains the main canvas. */
.lens-v2 .lens-image-stage {
  position: absolute;
  inset: 0 0 var(--lens-peek) 0;
  margin: auto;
  width: -moz-fit-content;
  width: fit-content;
  height: -moz-fit-content;
  height: fit-content;
  max-width: 100%;
  max-height: 100%;
  display: none;
  line-height: 0;
  z-index: 2;
  transition: inset 0.4s var(--lens-ease);
}
.lens-v2.lens-has-image .lens-image-stage { display: block; }
.lens-v2 .lens-image-stage > img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100vw;
  max-height: calc(100dvh - var(--lens-peek));
  object-fit: contain;
}
.lens-v2 .lens-overlay-layer { position: absolute; inset: 0; pointer-events: none; }

/* Pinch/pan/double-tap are handled in JS, so the browser must not claim the
   touch stream first. Scoped to the stage: the report sheet below still scrolls
   natively. Annotation chips keep pointer-events:auto and stay tappable — the
   gesture layer only takes over once a second finger lands or the pointer
   travels past the tap slop. */
.lens-v2 .lens-stage { touch-action: none; }
.lens-v2 .lens-image-stage { touch-action: none; }
/* The report sheet and the compare handle run their own drag loops. */
.lens-v2 .lens-sheet-scroll { touch-action: pan-y; }

/* Floating viewer controls: 44px targets, thumb-reachable, out of the way of the
   anatomy. Hidden until a study is actually on screen. */
.lens-v2 .lens-viewer-controls {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  display: none;
  flex-direction: column;
  gap: 8px;
}
.lens-v2.lens-has-image .lens-viewer-controls { display: flex; }
.lens-v2.lens-analyzing .lens-viewer-controls { opacity: 0; pointer-events: none; }
.lens-v2 .lens-viewer-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 12, 20, 0.62);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.lens-v2 .lens-viewer-btn:hover { background: rgba(15, 23, 42, 0.86); border-color: rgba(56, 189, 248, 0.5); }
.lens-v2 .lens-viewer-btn:active { transform: scale(0.94); }
.lens-v2 .lens-viewer-btn:focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; }
.lens-v2 .lens-viewer-btn[aria-pressed="true"] { background: rgba(56, 189, 248, 0.24); border-color: rgba(56, 189, 248, 0.66); }

/* Fullscreen: the study takes the whole screen, chrome steps back. */
.lens-v2.lens-fullscreen .lens-image-stage { inset: 0 !important; }
.lens-v2.lens-fullscreen .lens-image-stage > img,
.lens-v2.lens-fullscreen .lens-image-stage > video.lens-cine-video { max-height: 100dvh; }
.lens-v2.lens-fullscreen .lens-sheet,
.lens-v2.lens-fullscreen .lens-capturebar,
.lens-v2.lens-fullscreen .lens-modes-wrap,
.lens-v2.lens-fullscreen .lens-scrim { opacity: 0; pointer-events: none; }
.lens-v2.lens-fullscreen .lens-topbar { opacity: 0.35; }
.lens-v2.lens-fullscreen .lens-topbar:hover { opacity: 1; }

/* These float over the study itself, so they only lighten in explicit light
   theme; the image stage stays dark under an OS light preference alone. */
@media (prefers-color-scheme: light) {
  :root[data-theme="light"] .lens-v2 .lens-viewer-btn {
    border-color: rgba(15, 23, 42, 0.14);
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
  }
  :root[data-theme="light"] .lens-v2 .lens-viewer-btn:hover { background: #fff; border-color: rgba(2, 132, 199, 0.5); }
}
.lens-heatmap-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity .25s ease; mix-blend-mode: screen; z-index: 1; }
.lens-visualization-notice {
  position: absolute; right: 12px; top: 12px; z-index: 4; pointer-events: none;
  max-width: calc(100% - 24px); padding: 6px 9px; border-radius: 8px;
  color: rgba(255,255,255,.94); background: rgba(8,12,20,.72);
  border: 1px solid rgba(255,255,255,.2); backdrop-filter: blur(8px);
  font-size: 10px; font-weight: 700; line-height: 1.25; letter-spacing: .02em;
}
.lens-visualization-notice.hidden { display: none; }

/* Drag & drop dropzone */
.lens-dropzone-hint {
  position: absolute; inset: 12px; z-index: 20; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border-radius: 18px; border: 2px dashed color-mix(in srgb, var(--lens-accent, #6366f1) 65%, transparent);
  background: color-mix(in srgb, var(--lens-accent, #6366f1) 12%, rgba(8, 10, 20, 0.55));
  color: #fff; opacity: 0; transform: scale(0.98); transition: opacity .16s ease, transform .16s ease;
  backdrop-filter: blur(3px);
}
.lens-dropzone-hint span { font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.lens-dropzone-hint small { font-size: 12px; opacity: .75; }
.lens-stage.lens-dragover .lens-dropzone-hint { opacity: 1; transform: scale(1); }

/* MedGemma base-inference report */
.lens-base-report { display: flex; flex-direction: column; gap: 12px; }
.lens-base-badge {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em;
  color: #fff; background: linear-gradient(90deg, #6366f1, #8b5cf6);
  box-shadow: 0 4px 14px color-mix(in srgb, #6366f1 40%, transparent);
}
.lens-base-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #a5f3fc; box-shadow: 0 0 8px #a5f3fc; animation: lensBasePulse 1.6s ease-in-out infinite; }
@keyframes lensBasePulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }
.lens-base-disclaimer { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--lens-muted, #9aa4b2); border-left: 3px solid color-mix(in srgb, #f59e0b 60%, transparent); padding-left: 10px; }
.lens-base-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lens-base-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; background: color-mix(in srgb, var(--lens-accent, #6366f1) 10%, transparent); border: 1px solid color-mix(in srgb, var(--lens-accent, #6366f1) 22%, transparent); font-size: 12.5px; }
.lens-base-chip .k { color: var(--lens-muted, #9aa4b2); }
.lens-base-chip .v { font-weight: 700; }
.lens-base-chip .c { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: color-mix(in srgb, var(--lens-accent, #6366f1) 24%, transparent); }
.lens-base-sec { margin: 0; }
.lens-base-sec h4 { margin: 0 0 6px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--lens-muted, #9aa4b2); }
.lens-base-sec ul { margin: 0; padding-left: 18px; }
.lens-base-sec li { margin: 3px 0; line-height: 1.5; }
.lens-base-finding { padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, #ef4444 8%, transparent); border: 1px solid color-mix(in srgb, #ef4444 20%, transparent); margin-bottom: 6px; }
.lens-base-finding .lf-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lens-base-finding .lf-loc { font-size: 12px; color: var(--lens-muted, #9aa4b2); }
.lens-base-finding .lf-conf { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, #ef4444 22%, transparent); }
.lens-base-finding .lf-ev { margin-top: 4px; font-size: 12.5px; color: var(--lens-muted, #b6bece); line-height: 1.5; }
.lens-base-urgent h4 { color: #f87171; }
.lens-base-urgent ul { color: #fca5a5; }
.lens-base-muted { color: var(--lens-muted, #9aa4b2); font-size: 13px; }
.lens-base-limits li { color: var(--lens-muted, #9aa4b2); font-size: 12.5px; }
@media (prefers-color-scheme: light) { .lens-base-chip .v { color: #1f2937; } }

/* Premium Glassmorphism Report Export Toolbar */
.lens-report-actions {
  display: flex;
  gap: 14px;
  margin: 6px 0 18px;
  flex-wrap: wrap;
  align-items: center;
}
.lens-report-actions.hidden { display: none; }
.lens-report-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 20px;
  border-radius: 16px;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.015em;
  color: #ffffff;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.35);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1),
              background 180ms cubic-bezier(0.16, 1, 0.3, 1),
              border-color 180ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 180ms cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-user-select: none;
}
.lens-report-action:hover {
  background: rgba(34, 211, 238, 0.22);
  border-color: rgba(56, 189, 248, 0.6);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(34, 211, 238, 0.28), 0 0 14px rgba(56, 189, 248, 0.35);
}
.lens-report-action:active {
  transform: scale(0.98);
  background: rgba(34, 211, 238, 0.28);
  box-shadow: 0 4px 12px rgba(34, 211, 238, 0.2);
}
.lens-report-action:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 3px;
}
.lens-report-action svg {
  flex: none;
  width: 18px;
  height: 18px;
  color: #38bdf8;
}

/* Export states. The button owns its own progress so a tap is acknowledged on
   the very next frame, long before the report is baked. */
.lens-report-action[disabled] { cursor: progress; }
.lens-report-action.is-busy {
  background: rgba(34, 211, 238, 0.2);
  border-color: rgba(56, 189, 248, 0.55);
  transform: none;
}
.lens-report-action.is-busy:hover { transform: none; }
.lens-report-action.is-busy svg { display: none; }
.lens-report-action.is-busy::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(56, 189, 248, 0.28);
  border-top-color: #38bdf8;
  animation: lensActionSpin 0.75s linear infinite;
}
@keyframes lensActionSpin { to { transform: rotate(360deg); } }
.lens-report-action.has-error {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.55);
}
.lens-report-action.has-error svg { color: #f87171; }
@media (prefers-reduced-motion: reduce) {
  .lens-report-action.is-busy::before { animation-duration: 2.4s; }
}

/* PDF export (browser print) — show only the printable report */
#lensPrintRoot { display: none; }
@media print {
  /* ---- Professional radiology-style report (light, print-ready) ---- */
  @page { margin: 14mm 12mm; }
  body.lens-printing { background: #fff !important; }
  body.lens-printing > *:not(#lensPrintRoot) { display: none !important; }
  body.lens-printing #lensPrintRoot { display: block !important; }
  #lensPrintRoot {
    --lp-accent: #1d4ed8;
    --lp-ink: #0b1220;
    --lp-muted: #475569;
    --lp-line: #d7deea;
    color: var(--lp-ink);
    background: #fff;
    font-family: "Helvetica Neue", Arial, "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 11.5pt;
    line-height: 1.5;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #lensPrintRoot * { box-sizing: border-box; }

  #lensPrintRoot .lp-head {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 2.5pt solid var(--lp-accent);
    padding-bottom: 8pt; margin-bottom: 14pt;
  }
  #lensPrintRoot .lp-brand { display: flex; align-items: center; gap: 9pt; }
  #lensPrintRoot .lp-logo {
    display: grid; place-items: center; width: 26pt; height: 26pt;
    background: var(--lp-accent); color: #fff; border-radius: 7pt;
    font-weight: 800; font-size: 15pt; line-height: 1;
  }
  #lensPrintRoot .lp-brand-text { font-size: 17pt; font-weight: 600; letter-spacing: -0.01em; color: var(--lp-ink); }
  #lensPrintRoot .lp-brand-text strong { font-weight: 800; }
  #lensPrintRoot .lp-head-meta { text-align: right; }
  #lensPrintRoot .lp-doc-type { font-size: 10pt; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--lp-accent); }
  #lensPrintRoot .lp-doc-ref { font-size: 8.5pt; color: var(--lp-muted); margin-top: 2pt; }

  #lensPrintRoot .lp-title { font-size: 18pt; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 10pt; color: var(--lp-ink); }

  #lensPrintRoot .lp-meta {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4pt 24pt;
    margin: 0 0 14pt; padding: 9pt 12pt;
    background: #f4f7fc; border: 0.75pt solid var(--lp-line); border-radius: 7pt;
  }
  #lensPrintRoot .lp-meta div { display: flex; gap: 6pt; }
  #lensPrintRoot .lp-meta dt { flex: 0 0 auto; font-weight: 700; font-size: 8.5pt; text-transform: uppercase; letter-spacing: 0.05em; color: var(--lp-muted); min-width: 92pt; }
  #lensPrintRoot .lp-meta dd { margin: 0; font-size: 9.5pt; color: var(--lp-ink); }

  #lensPrintRoot .lp-img { margin: 0 0 16pt; text-align: center; break-inside: avoid; }
  #lensPrintRoot .lp-img img { max-width: 100%; max-height: 108mm; border: 0.75pt solid var(--lp-line); border-radius: 6pt; }
  #lensPrintRoot .lp-img figcaption { margin-top: 5pt; font-size: 8.5pt; color: var(--lp-muted); font-style: italic; }

  #lensPrintRoot .lp-section { margin: 0 0 13pt; break-inside: avoid; }
  #lensPrintRoot .lp-section h2 {
    font-size: 12.5pt; font-weight: 700; color: var(--lp-accent);
    margin: 0 0 6pt; padding-bottom: 3pt; border-bottom: 0.75pt solid var(--lp-line);
    letter-spacing: 0.01em;
  }
  #lensPrintRoot p { margin: 0 0 6pt; }
  #lensPrintRoot .lp-impression { font-size: 12pt; font-weight: 500; }
  #lensPrintRoot ul { margin: 4pt 0; padding-left: 16pt; }
  #lensPrintRoot li { margin: 4pt 0; }
  #lensPrintRoot .lp-findings li { list-style: none; margin-left: -12pt; padding-left: 12pt; border-left: 2pt solid var(--lp-accent); margin-bottom: 8pt; }
  #lensPrintRoot .lp-finding-h { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6pt; }
  #lensPrintRoot .lp-finding-h b { font-size: 11pt; }
  #lensPrintRoot .lp-tag {
    display: inline-block; font-size: 8pt; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    padding: 1pt 6pt; border-radius: 999px; background: #e8effc; color: var(--lp-accent);
  }
  #lensPrintRoot .lp-tag.muted { background: #eef1f6; color: var(--lp-muted); }
  #lensPrintRoot .lp-tag-conf { background: var(--lp-accent); color: #fff; }
  #lensPrintRoot .muted { color: var(--lp-muted); font-size: 10pt; }

  #lensPrintRoot .lp-foot { margin-top: 18pt; padding-top: 8pt; border-top: 0.75pt solid var(--lp-line); }
  #lensPrintRoot .lp-disclaimer { font-size: 8.5pt; color: var(--lp-muted); margin-bottom: 5pt; }
  #lensPrintRoot .lp-foot-row { display: flex; justify-content: space-between; gap: 12pt; font-size: 8.5pt; color: var(--lp-muted); }
  #lensPrintRoot .lp-foot-row strong { color: var(--lp-accent); }
  #lensPrintRoot .lp-share { text-align: right; }
}
.lens-v2 #lensCapturedImage { display: none !important; }

/* Framing reticle — live only. */
.lens-v2 .lens-reticle {
  position: absolute;
  inset: max(84px, calc(var(--lens-safe-top) + 74px)) 30px auto 30px;
  height: min(58vh, 460px);
  pointer-events: none;
  z-index: 3;
  opacity: 0.9;
  transition: opacity 0.35s var(--lens-ease);
}
.lens-v2 .lens-reticle i {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 2.5px solid rgba(255, 255, 255, 0.85);
}
.lens-v2 .lens-reticle i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.lens-v2 .lens-reticle i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.lens-v2 .lens-reticle i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.lens-v2 .lens-reticle i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.lens-v2.lens-has-image .lens-reticle { opacity: 0; }

/* Legibility scrims behind floating controls. */
.lens-v2 .lens-scrim { position: absolute; left: 0; right: 0; pointer-events: none; z-index: 4; }
.lens-v2 .lens-scrim-top { top: 0; height: 190px; background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0)); }
.lens-v2 .lens-scrim-bottom { bottom: 0; height: 300px; background: linear-gradient(0deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0)); transition: opacity 0.3s ease; }
.lens-v2:has(.lens-sheet:not(.hidden)) .lens-scrim-bottom { opacity: 0; }

/* ---- Empty / permission state ------------------------------------------ */
.lens-v2 .lens-empty-state {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 40px;
  pointer-events: none;
}
.lens-v2 .lens-empty-state.hidden,
.lens-v2.lens-has-image .lens-empty-state { display: none; }
.lens-v2 .lens-empty-state img { width: 88px; height: 88px; object-fit: contain; margin-bottom: 6px; filter: drop-shadow(0 10px 30px rgba(100, 210, 255, 0.35)); }
.lens-v2 .lens-empty-state strong { font-size: 1.15rem; font-weight: 700; }
.lens-v2 .lens-empty-state span { font-size: 0.9rem; color: rgba(255, 255, 255, 0.72); max-width: 300px; }
.lens-v2 .lens-enable-camera {
  pointer-events: auto;
  margin-top: 14px;
  padding: 12px 24px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #002133;
  background: linear-gradient(135deg, #7fdcff, var(--lens-accent));
  box-shadow: 0 12px 30px rgba(100, 210, 255, 0.4);
  cursor: pointer;
}

/* ---- Floating top bar --------------------------------------------------- */
.lens-v2 .lens-topbar-v2 {
  position: absolute;
  top: calc(var(--lens-safe-top) + 14px);
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  pointer-events: none;
}
.lens-v2 .lens-topbar-right { display: flex; gap: 10px; pointer-events: none; }
.lens-v2 .lens-fab {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0.5px solid var(--lens-hairline);
  border-radius: 50%;
  color: #fff;
  background: var(--lens-glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.2s var(--lens-ease), background 0.2s ease;
}
.lens-v2 .lens-fab:active { transform: scale(0.9); }
.lens-v2 .lens-fab[aria-pressed="true"] { background: rgba(100, 210, 255, 0.9); color: #002133; }

/* ---- Study-mode segmented control + modality pill ---------------------- */
.lens-v2 .lens-modes-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--lens-safe-bottom) + 128px);
  z-index: 18;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  pointer-events: none;
  transition: opacity 0.3s var(--lens-ease), transform 0.3s var(--lens-ease);
}
.lens-v2.lens-analyzing .lens-modes-wrap,
.lens-v2:has(.lens-sheet:not(.hidden)) .lens-modes-wrap { opacity: 0; transform: translateY(14px); pointer-events: none; }

.lens-v2 .lens-modality-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 0.5px solid var(--lens-hairline);
  border-radius: 999px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--lens-glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  cursor: pointer;
}
.lens-v2 .lens-modality-pill.is-custom { background: rgba(100, 210, 255, 0.22); border-color: rgba(100, 210, 255, 0.5); }
.lens-v2 .lens-modality-pill svg { opacity: 0.85; }

.lens-v2 .lens-segment {
  pointer-events: auto;
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  border: 0.5px solid var(--lens-hairline);
  border-radius: 999px;
  background: var(--lens-glass-strong);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.36);
}
.lens-v2 .lens-segment::-webkit-scrollbar { display: none; }
.lens-v2 .lens-segment button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.25s var(--lens-ease), transform 0.2s var(--lens-ease);
}
.lens-v2 .lens-segment button.active {
  color: #00212e;
  background: linear-gradient(135deg, #a9e9ff, var(--lens-accent));
  box-shadow: 0 4px 14px rgba(100, 210, 255, 0.45);
}
.lens-v2 .lens-segment button:active { transform: scale(0.94); }

/* ---- Viewfinder zoom readout -------------------------------------------- */
/* Sits just above the shutter, out of the reticle, and is a 44px tap target in
   its own right so zoom is reachable without a two-finger gesture. */
.lens-v2 .lens-zoom-chip {
  position: absolute;
  left: 50%;
  bottom: calc(var(--lens-safe-bottom) + 108px);
  transform: translateX(-50%);
  z-index: 19;
  min-width: 56px;
  height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0.5px solid var(--lens-hairline);
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--lens-glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  cursor: pointer;
  transition: color 0.2s var(--lens-ease), background 0.2s var(--lens-ease),
              border-color 0.2s var(--lens-ease), opacity 0.25s var(--lens-ease);
}
.lens-v2 .lens-zoom-chip[hidden] { display: none; }
.lens-v2 .lens-zoom-chip.active {
  color: #fde68a;
  border-color: rgba(253, 230, 138, 0.5);
  background: rgba(253, 230, 138, 0.14);
}
.lens-v2 .lens-zoom-chip.pulse { animation: lensZoomPulse 0.32s var(--lens-ease); }
@keyframes lensZoomPulse {
  0% { transform: translateX(-50%) scale(1); }
  45% { transform: translateX(-50%) scale(1.12); }
  100% { transform: translateX(-50%) scale(1); }
}
/* Hidden alongside the capture bar whenever the sheet or the scan takes over. */
.lens-v2:has(.lens-sheet:not(.hidden)) .lens-zoom-chip,
.lens-v2.lens-analyzing .lens-zoom-chip,
.lens-v2.lens-has-image .lens-zoom-chip { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .lens-v2 .lens-zoom-chip.pulse { animation: none; }
}

/* ---- Bottom capture bar ------------------------------------------------- */
.lens-v2 .lens-capturebar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--lens-safe-bottom) + 26px);
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 46px;
  pointer-events: none;
  transition: opacity 0.3s var(--lens-ease), transform 0.35s var(--lens-ease);
}
.lens-v2:has(.lens-sheet:not(.hidden)) .lens-capturebar,
.lens-v2.lens-analyzing .lens-capturebar { opacity: 0; transform: translateY(40px); pointer-events: none; }
.lens-v2 .lens-side-btn {
  pointer-events: auto;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 0.5px solid var(--lens-hairline);
  border-radius: 50%;
  color: #fff;
  background: var(--lens-glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  cursor: pointer;
  transition: transform 0.2s var(--lens-ease);
}
.lens-v2 .lens-side-btn:active { transform: scale(0.9); }

.lens-v2 .lens-shutter {
  pointer-events: auto;
  position: relative;
  width: 78px;
  height: 78px;
  border: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.lens-v2 .lens-shutter-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.92);
  transition: transform 0.25s var(--lens-ease);
}
.lens-v2 .lens-shutter-core {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s var(--lens-ease), background 0.25s ease;
}
.lens-v2 .lens-shutter:active .lens-shutter-core { transform: scale(0.86); }
.lens-v2 .lens-shutter:active .lens-shutter-ring { transform: scale(0.94); }
.lens-v2 .lens-shutter-spinner {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--lens-accent);
  border-right-color: var(--lens-accent);
  opacity: 0;
}
.lens-v2 .lens-shutter.is-analyzing .lens-shutter-core { background: var(--lens-accent); transform: scale(0.5); border-radius: 30%; }
.lens-v2 .lens-shutter.is-analyzing .lens-shutter-spinner { opacity: 1; animation: lensSpin 0.9s linear infinite; }
@keyframes lensSpin { to { transform: rotate(360deg); } }

/* ---- Premium AI scan animation ----------------------------------------- */
.lens-v2 .lens-scan {
  position: absolute;
  inset: 0;
  z-index: 9;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--lens-ease);
}
.lens-v2.lens-analyzing .lens-scan { opacity: 1; }
/* While processing, the "Upload any medical image" prompt contradicts what is
   actually happening, so it steps aside for the scan animation. */
.lens-v2.lens-analyzing .lens-empty-state { opacity: 0; transition: opacity 0.25s var(--lens-ease); }
.lens-v2 .lens-scan-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(100, 210, 255, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 210, 255, 0.14) 1px, transparent 1px);
  background-size: 38px 38px;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 45%, #000 30%, transparent 75%);
  mask-image: radial-gradient(70% 60% at 50% 45%, #000 30%, transparent 75%);
  animation: lensGridPulse 2.6s ease-in-out infinite;
}
@keyframes lensGridPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.7; } }
.lens-v2 .lens-scan-sweep {
  position: absolute;
  left: 0;
  right: 0;
  height: 160px;
  top: -160px;
  background: linear-gradient(180deg, rgba(100, 210, 255, 0) 0%, rgba(100, 210, 255, 0.25) 60%, rgba(160, 235, 255, 0.9) 100%);
  box-shadow: 0 0 34px 8px rgba(100, 210, 255, 0.55);
  border-bottom: 2px solid rgba(180, 240, 255, 0.95);
  animation: lensSweep 2.2s var(--lens-ease) infinite;
}
@keyframes lensSweep {
  0% { top: -160px; }
  100% { top: 100%; }
}
.lens-v2 .lens-scan-corner {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 3px solid var(--lens-accent);
  filter: drop-shadow(0 0 8px rgba(100, 210, 255, 0.7));
  animation: lensCornerPulse 1.8s ease-in-out infinite;
}
.lens-v2 .lens-scan-corner.tl { top: 16%; left: 12%; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.lens-v2 .lens-scan-corner.tr { top: 16%; right: 12%; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.lens-v2 .lens-scan-corner.bl { bottom: 24%; left: 12%; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.lens-v2 .lens-scan-corner.br { bottom: 24%; right: 12%; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
@keyframes lensCornerPulse { 0%, 100% { opacity: 0.55; transform: scale(1); } 50% { opacity: 1; transform: scale(1.06); } }

.lens-v2 .lens-scan-status {
  position: absolute;
  left: 50%;
  bottom: calc(var(--lens-safe-bottom) + 150px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 0.5px solid rgba(100, 210, 255, 0.4);
  background: rgba(8, 14, 22, 0.72);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lens-v2 .lens-scan-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--lens-accent);
  box-shadow: 0 0 12px 2px rgba(100, 210, 255, 0.8);
  animation: lensDot 1s ease-in-out infinite;
}
@keyframes lensDot { 0%, 100% { opacity: 0.4; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } }
.lens-v2 .lens-scan-label { font-size: 0.86rem; font-weight: 600; color: #eaf7ff; letter-spacing: 0.01em; }

/* ---- Advanced sheet (modality + power modes) --------------------------- */
.lens-v2 .lens-advanced { position: absolute; inset: 0; z-index: 40; }
.lens-v2 .lens-advanced[hidden] { display: none; }
.lens-v2 .lens-advanced-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.lens-v2 .lens-advanced.open .lens-advanced-backdrop { opacity: 1; }
.lens-v2 .lens-advanced-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 20px calc(var(--lens-safe-bottom) + 26px);
  border-radius: 28px 28px 0 0;
  background: var(--lens-glass-strong);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  backdrop-filter: blur(30px) saturate(1.6);
  border-top: 0.5px solid var(--lens-hairline);
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.4s var(--lens-ease);
}
.lens-v2 .lens-advanced.open .lens-advanced-card { transform: translateY(0); }
.lens-v2 .lens-adv-handle {
  display: block;
  width: 40px;
  height: 5px;
  margin: 4px auto 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.32);
  cursor: pointer;
}
.lens-v2 .lens-advanced-card .eyebrow { color: var(--lens-accent); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; margin: 0; }
.lens-v2 .lens-advanced-card h3 { margin: 2px 0 16px; font-size: 1.15rem; }
.lens-v2 .lens-adv-label { font-size: 0.82rem; font-weight: 700; margin: 4px 0 10px; color: rgba(255, 255, 255, 0.9); }
.lens-v2 .lens-adv-label span { font-weight: 400; color: rgba(255, 255, 255, 0.5); }
.lens-v2 .lens-advanced-card .lens-mode-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 0;
  overflow: visible;
  background: none;
}
.lens-v2 .lens-advanced-card .lens-mode-strip button {
  border: 0.5px solid var(--lens-hairline);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.lens-v2 .lens-advanced-card .lens-mode-strip button.active {
  background: linear-gradient(135deg, #a9e9ff, var(--lens-accent));
  color: #00212e;
  border-color: transparent;
}
.lens-v2 .lens-advanced-done {
  width: 100%;
  margin-top: 4px;
  padding: 14px;
  border: 0;
  border-radius: 16px;
  font-weight: 700;
  font-size: 0.98rem;
  color: #002133;
  background: linear-gradient(135deg, #a9e9ff, var(--lens-accent));
  cursor: pointer;
}

/* ---- Analysis report bottom sheet -------------------------------------- */
.lens-v2 .lens-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: block;
  height: auto;
  background: none;
  pointer-events: none;
}
.lens-v2 .lens-sheet.hidden { display: none; }
.lens-v2 .lens-sheet-panel {
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  height: var(--lens-sheet-panel-h);
  max-height: var(--lens-sheet-panel-h);
  margin: 0;
  padding: 0 0 var(--lens-safe-bottom);
  border-radius: 26px 26px 0 0;
  background: var(--lens-glass-strong);
  -webkit-backdrop-filter: blur(34px) saturate(1.7);
  backdrop-filter: blur(34px) saturate(1.7);
  border-top: 0.5px solid var(--lens-hairline);
  box-shadow: 0 -22px 60px rgba(0, 0, 0, 0.55);
  /* Default resting stop = collapsed. Medium/full overridden by [data-snap]. */
  transform: translateY(var(--lens-snap-collapsed));
  transition: transform 0.44s var(--lens-ease);
  will-change: transform;
}
.lens-v2 .lens-sheet[data-snap="medium"] .lens-sheet-panel { transform: translateY(var(--lens-snap-medium)); }
.lens-v2 .lens-sheet[data-snap="full"] .lens-sheet-panel,
.lens-v2 .lens-sheet.expanded .lens-sheet-panel { transform: translateY(var(--lens-snap-full)); }
/* While the finger is down, JS drives an inline transform — kill the transition so it
   tracks 1:1, then re-enable it on release for a smooth snap. */
.lens-v2 .lens-sheet-panel.is-dragging { transition: none; }

.lens-v2 .lens-sheet-grabber {
  flex: 0 0 auto;
  display: block;
  width: 100%;
  padding: 9px 0 5px;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
}
.lens-v2 .lens-sheet-grabber:active { cursor: grabbing; }
.lens-v2 .lens-sheet-grabber i {
  display: block;
  width: 32px;
  height: 4px;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  transition: background 0.2s ease, width 0.2s ease;
}
.lens-v2 .lens-sheet-grabber:hover i,
.lens-v2 .lens-sheet-panel.is-dragging .lens-sheet-grabber i { background: rgba(255, 255, 255, 0.4); width: 40px; }

.lens-v2 .lens-sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 20px 10px;
}
.lens-v2 .lens-sheet-head .eyebrow { color: var(--lens-accent); font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; margin: 0; }
.lens-v2 .lens-sheet-head h3 { margin: 3px 0 0; font-size: 1.14rem; font-weight: 700; line-height: 1.25; }
.lens-v2 .lens-sheet-head-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.lens-v2 .lens-ghost-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0.5px solid var(--lens-hairline);
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: transform 0.2s var(--lens-ease), background 0.2s ease;
}
.lens-v2 .lens-ghost-icon:active { transform: scale(0.9); background: rgba(100, 210, 255, 0.25); }

.lens-v2 .lens-overlay-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 20px 16px;
}
.lens-v2 .lens-overlay-controls::-webkit-scrollbar { display: none; }
.lens-v2 .lens-toggle-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-user-select: none;
}
.lens-v2 .lens-toggle-chip input { position: absolute; opacity: 0; pointer-events: none; }
.lens-v2 .lens-toggle-chip::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid rgba(56, 189, 248, 0.5);
  background: transparent;
  transition: all 180ms ease;
  flex: none;
}
.lens-v2 .lens-toggle-btn::before { display: none; }
.lens-v2 .lens-toggle-chip:hover {
  background: rgba(34, 211, 238, 0.15);
  border-color: rgba(34, 211, 238, 0.5);
  transform: translateY(-1px);
}
.lens-v2 .lens-toggle-chip:has(input:checked),
.lens-v2 .lens-toggle-chip.active {
  color: #ffffff;
  border-color: rgba(103, 232, 249, 0.6);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.85), rgba(14, 165, 233, 0.95));
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.35);
}
.lens-v2 .lens-toggle-chip:has(input:checked)::before,
.lens-v2 .lens-toggle-chip.active::before {
  background: #ffffff;
  border-color: #ffffff;
  box-shadow: inset 0 0 0 2px rgba(6, 182, 212, 0.9);
}
.lens-v2 .lens-toggle-chip:active { transform: scale(0.97); }

.lens-chip-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.35);
  margin-left: 4px;
}
.lens-chip-badge svg { color: #38bdf8; flex: none; }

.lens-v2 .lens-sheet-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px 26px;
  overscroll-behavior: contain;
}
.lens-v2 .lens-sheet .lens-status { margin: 0 0 14px; }
.lens-v2 .lens-sheet .lens-safety { margin-top: 16px; font-size: 0.72rem; color: rgba(255, 255, 255, 0.45); }

/* Report hero (always in the peek). */
.lens-v2 .lens-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px 0 18px;
  border-bottom: 0.5px solid var(--lens-hairline);
  margin-bottom: 16px;
}
.lens-v2 .lens-hero .lens-conf { flex: 0 0 auto; position: relative; width: 84px; height: 84px; display: grid; place-items: center; }
.lens-v2 .lens-hero .lens-conf-ring { position: absolute; inset: 0; width: 84px; height: 84px; transform: rotate(-90deg); }
.lens-v2 .lens-conf-track { fill: none; stroke: rgba(255, 255, 255, 0.12); stroke-width: 3; }
.lens-v2 .lens-conf-fill { fill: none; stroke-width: 3; stroke-linecap: round; transition: stroke-dasharray 0.8s var(--lens-ease); }
.lens-v2 .lens-conf-good .lens-conf-fill { stroke: #34e2a0; }
.lens-v2 .lens-conf-warn .lens-conf-fill { stroke: #ffcf5c; }
.lens-v2 .lens-conf-low .lens-conf-fill { stroke: var(--lens-danger); }
.lens-v2 .lens-hero .lens-conf-num { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.lens-v2 .lens-hero .lens-conf-num i { font-size: 0.8rem; font-style: normal; opacity: 0.7; }
.lens-v2 .lens-hero .lens-conf-label { position: absolute; bottom: 8px; font-size: 0.56rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.6; }
.lens-v2 .lens-hero-text { flex: 1 1 auto; min-width: 0; }
.lens-v2 .lens-hero-type { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.lens-v2 .lens-hero-type strong { font-size: 1rem; font-weight: 700; }
.lens-v2 .lens-hero-impression { margin: 0; font-size: 0.92rem; line-height: 1.45; color: rgba(255, 255, 255, 0.92); }
.lens-v2 .lens-hero-quality { margin: 8px 0 0; font-size: 0.78rem; color: rgba(255, 255, 255, 0.6); }
.lens-v2 .lens-hero-quality span { color: var(--lens-accent); font-weight: 600; }

/* Collapsible groups. */
.lens-v2 .lens-group {
  border: 0.5px solid var(--lens-hairline);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 12px;
  overflow: hidden;
}
.lens-v2 .lens-group > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.96rem;
}
.lens-v2 .lens-group > summary::-webkit-details-marker { display: none; }
.lens-v2 .lens-group-ico { font-size: 1.05rem; line-height: 1; }
.lens-v2 .lens-group-title { flex: 1 1 auto; }
.lens-v2 .lens-group-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #00212e;
  background: var(--lens-accent);
}
.lens-v2 .lens-group-chev {
  width: 9px;
  height: 9px;
  border-right: 2px solid rgba(255, 255, 255, 0.5);
  border-bottom: 2px solid rgba(255, 255, 255, 0.5);
  transform: rotate(45deg);
  transition: transform 0.3s var(--lens-ease);
}
.lens-v2 .lens-group[open] > summary .lens-group-chev { transform: rotate(225deg); }
.lens-v2 .lens-group-body { padding: 0 16px 14px; }
.lens-v2 .lens-group-body .lens-rep-section { margin-top: 4px; }
.lens-v2 .lens-group-body .lens-rep-h { color: var(--lens-accent); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; margin: 12px 0 8px; display: block; }

/* ---- Floating Baihaqi AI assistant ------------------------------------- */
.lens-v2 .lens-ai-orb-wrap {
  position: absolute;
  right: 18px;
  bottom: calc(var(--lens-safe-bottom) + 132px);
  z-index: 32;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
.lens-v2 .lens-ai-orb-wrap[hidden] { display: none; }
.lens-v2 .lens-ai-orb-wrap { transition: bottom 0.46s var(--lens-ease), opacity 0.3s var(--lens-ease); }
.lens-v2:has(.lens-sheet:not(.hidden)) .lens-ai-orb-wrap { bottom: calc(var(--lens-peek, 300px) + 16px); }
/* No clean room for the orb once the sheet rises past collapsed — fade it out; it
   returns when the sheet is collapsed. */
.lens-v2:has(.lens-sheet[data-snap="medium"]) .lens-ai-orb-wrap,
.lens-v2:has(.lens-sheet[data-snap="full"]) .lens-ai-orb-wrap,
.lens-v2:has(.lens-sheet.expanded) .lens-ai-orb-wrap { opacity: 0; pointer-events: none; }
.lens-v2 .lens-ai-orb-wrap.is-in .lens-ai-orb { animation: lensOrbIn 0.5s var(--lens-ease) both; }
@keyframes lensOrbIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.lens-v2 .lens-ai-orb {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0.5px solid rgba(100, 210, 255, 0.5);
  padding: 0;
  background: radial-gradient(circle at 32% 28%, #1a3a52, #0a1a2a);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 0 rgba(100, 210, 255, 0.5);
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
  animation: lensOrbGlow 2.8s ease-in-out infinite;
}
@keyframes lensOrbGlow {
  0%, 100% { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 0 rgba(100, 210, 255, 0.5); }
  50% { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 8px rgba(100, 210, 255, 0); }
}
.lens-v2 .lens-ai-orb img { width: 46px; height: 46px; object-fit: contain; }
.lens-v2 .lens-ai-orb:active { transform: scale(0.9); }

.lens-v2 .lens-ai-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  border: 0.5px solid var(--lens-hairline);
  background: var(--lens-glass-strong);
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  backdrop-filter: blur(26px) saturate(1.6);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  transform-origin: bottom right;
  animation: lensMenuIn 0.28s var(--lens-ease) both;
}
.lens-v2 .lens-ai-menu[hidden] { display: none; }
@keyframes lensMenuIn { from { transform: scale(0.85) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.lens-v2 .lens-ai-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px 11px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease;
}
.lens-v2 .lens-ai-menu button span { font-size: 1.05rem; }
.lens-v2 .lens-ai-menu button:active { background: rgba(100, 210, 255, 0.2); }

/* ---- Zoom reset (repurposed as a chip) --------------------------------- */
.lens-v2 .lens-zoom-reset.hidden { display: none; }

/* ---- Light theme adaptation for the sheet ------------------------------ */
@media (prefers-color-scheme: light) {
  :root[data-theme="light"] .lens-v2 .lens-sheet-panel {
    background: rgba(248, 250, 253, 0.86);
    color: #0b1220;
  }
  :root[data-theme="light"] .lens-v2 .lens-sheet-panel h3,
  :root[data-theme="light"] .lens-v2 .lens-hero-impression,
  :root[data-theme="light"] .lens-v2 .lens-group > summary { color: #0b1220; }
  :root[data-theme="light"] .lens-v2 .lens-group { background: rgba(10, 30, 50, 0.04); border-color: rgba(10, 30, 50, 0.1); }
  :root[data-theme="light"] .lens-v2 .lens-toggle-chip { color: #33455c; background: rgba(10, 30, 50, 0.05); border-color: rgba(10, 30, 50, 0.12); }
}
:root[data-theme="dark"] .lens-v2 .lens-sheet-panel { background: var(--lens-glass-strong); color: #fff; }

/* ---- Small phones ------------------------------------------------------- */
@media (max-width: 380px) {
  .lens-v2 .lens-capturebar { gap: 34px; }
  .lens-v2 .lens-segment button { padding: 8px 14px; font-size: 0.82rem; }
  .lens-v2 .lens-shutter { width: 72px; height: 72px; }
  .lens-v2 .lens-shutter-core { width: 55px; height: 55px; }
}

/* ---- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .lens-v2 *,
  .lens-v2 .lens-scan-sweep,
  .lens-v2 .lens-scan-grid,
  .lens-v2 .lens-ai-orb { animation: none !important; }
  .lens-v2 .lens-sheet-panel,
  .lens-v2 .lens-advanced-card { transition: transform 0.15s ease; }
}

/* ---- Tablet / desktop: floating side panel, never covering the image ------
   From 768px up the report docks as a card on the right; the image keeps the rest
   of the stage as its canvas. Drag/snap is disabled here (JS also no-ops). */
@media (min-width: 768px) {
  .lens-v2 { --lens-side-panel-w: min(420px, 38vw); }
  /* Reserve the right column for the panel instead of the bottom strip. */
  .lens-v2 .lens-image-stage { inset: 0 var(--lens-side-panel-w) 0 0 !important; }
  .lens-v2 .lens-image-stage > img { max-height: 100dvh; }

  .lens-v2 .lens-sheet {
    left: auto;
    right: 0;
    top: 0;
    bottom: 0;
    width: var(--lens-side-panel-w);
    display: flex;
    align-items: stretch;
    padding: 16px 16px 16px 0;
    pointer-events: none;
  }
  .lens-v2 .lens-sheet-panel {
    width: 100%;
    height: auto !important;
    max-height: 100% !important;
    transform: none !important;
    border-radius: 22px;
    border: 0.5px solid var(--lens-hairline);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    padding-bottom: 0;
  }
  /* No drag handle needed when the panel is a fixed side card. */
  .lens-v2 .lens-sheet-grabber { display: none; }
  /* Orb has room beside the panel again. */
  .lens-v2:has(.lens-sheet[data-snap="medium"]) .lens-ai-orb-wrap,
  .lens-v2:has(.lens-sheet[data-snap="full"]) .lens-ai-orb-wrap,
  .lens-v2:has(.lens-sheet.expanded) .lens-ai-orb-wrap { opacity: 1; pointer-events: auto; }
  .lens-v2:has(.lens-sheet:not(.hidden)) .lens-ai-orb-wrap { bottom: calc(var(--lens-safe-bottom) + 24px); right: calc(var(--lens-side-panel-w) + 18px); }
}

/* ─── MedGemma Base Inference Mode ─── */
.lens-base-inference-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, #f59e0b22, #d9770622);
  border: 1px solid #f59e0b55;
  color: #f59e0b;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
  animation: lensBaseInferencePulse 3s ease-in-out infinite;
}

@keyframes lensBaseInferencePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
  50% { box-shadow: 0 0 12px 2px rgba(245, 158, 11, 0.15); }
}

.lens-base-inference-badge .lens-badge-icon {
  font-size: 1em;
}

.lens-base-disclaimer {
  font-size: 0.78rem;
  color: #94a3b8;
  font-style: italic;
  margin: 0 0 16px;
  padding: 8px 12px;
  border-left: 3px solid #f59e0b44;
  background: #f59e0b08;
  border-radius: 0 8px 8px 0;
  line-height: 1.5;
}

.lens-enhanced-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, #10b98122, #059e6f22);
  border: 1px solid #10b98155;
  color: #10b981;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}

.lens-annotation.ai-estimated {
  border-style: dashed !important;
  opacity: 0.85;
}

.lens-annotation.ai-estimated .lens-annotation-label::after {
  content: " (AI-est.)";
  font-size: 0.7em;
  opacity: 0.7;
  font-style: italic;
}

.lens-tier-tag.lens-tier-ai-estimated {
  background: #f59e0b22;
  color: #f59e0b;
  border: 1px solid #f59e0b44;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
}

/* Laterality chip on a finding — sided vs uncertain */
.lens-side-tag {
  font-style: normal;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: #6366f11f;
  color: #4f46e5;
  border: 1px solid #6366f13d;
}
.lens-side-tag.lens-side-uncertain {
  background: #94a3b81f;
  color: #64748b;
  border: 1px solid #94a3b83d;
}

/* Orientation banner under the report hero */
.lens-orientation-note {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 10px 0 4px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.35;
  border: 1px solid transparent;
}
.lens-orientation-note strong { font-size: 0.78rem; letter-spacing: 0.02em; }
.lens-orientation-note.reliable {
  background: #10b98115;
  color: #047857;
  border-color: #10b9813d;
}
.lens-orientation-note.uncertain {
  background: #f59e0b17;
  color: #b45309;
  border-color: #f59e0b3d;
}

/* R / L radiological convention edge guides over the image */
.lens-orient-guide { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.lens-orient-guide span {
  position: absolute;
  top: 8px;
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.62);
  color: #fff;
  letter-spacing: 0.04em;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.lens-orient-guide .lens-orient-r { left: 8px; }
.lens-orient-guide .lens-orient-l { right: 8px; }

@media (prefers-color-scheme: dark) {
  .lens-orientation-note.reliable { background: #10b9811f; color: #6ee7b7; }
  .lens-orientation-note.uncertain { background: #f59e0b1f; color: #fbbf24; }
  .lens-side-tag { background: #6366f12e; color: #a5b4fc; }
  .lens-side-tag.lens-side-uncertain { background: #94a3b82e; color: #cbd5e1; }
}

/* ---- Lens History modal ---- */
.lens-history-modal { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: flex-end; justify-content: center; }
.lens-history-modal.hidden { display: none; }
.lens-history-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 23, 0.55); backdrop-filter: blur(2px); }
.lens-history-sheet {
  position: relative;
  width: min(560px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--lens-surface, #ffffff);
  color: var(--lens-ink, #0f172a);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(2, 6, 23, 0.4);
  animation: lensHistoryRise 0.22s ease;
}
@keyframes lensHistoryRise { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (min-width: 640px) {
  .lens-history-modal { align-items: center; }
  .lens-history-sheet { border-radius: 20px; }
}
.lens-history-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; border-bottom: 1px solid rgba(100, 116, 139, 0.16); }
.lens-history-head h3 { margin: 0; font-size: 1.05rem; }
.lens-history-head-actions { display: flex; align-items: center; gap: 8px; }
.lens-history-clear { background: none; border: 1px solid rgba(239, 68, 68, 0.4); color: #ef4444; border-radius: 10px; padding: 5px 10px; font-size: 0.78rem; cursor: pointer; }
.lens-history-close { background: none; border: none; font-size: 1.5rem; line-height: 1; color: inherit; cursor: pointer; padding: 0 6px; }
.lens-history-body { overflow-y: auto; padding: 10px 14px 20px; }
.lens-history-empty { text-align: center; color: #64748b; font-size: 0.9rem; padding: 26px 12px; }
.lens-history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lens-history-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(100, 116, 139, 0.18);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.lens-history-item:hover { background: color-mix(in srgb, var(--lens-accent, #6366f1) 8%, transparent); border-color: color-mix(in srgb, var(--lens-accent, #6366f1) 40%, transparent); }
.lens-history-thumb { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; border-radius: 10px; background: color-mix(in srgb, var(--lens-accent, #6366f1) 12%, transparent); }
.lens-history-thumb.no-image { color: #94a3b8; }
.lens-history-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lens-history-meta strong { font-size: 0.9rem; }
.lens-history-summary { font-size: 0.8rem; color: #475569; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lens-history-time { font-size: 0.72rem; color: #94a3b8; }
.lens-history-del { background: none; border: none; color: #94a3b8; font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.lens-history-del:hover { color: #ef4444; background: rgba(239, 68, 68, 0.12); }

@media (prefers-color-scheme: dark) {
  .lens-history-sheet { background: #0f172a; color: #e2e8f0; }
  .lens-history-summary { color: #94a3b8; }
  .lens-history-item { border-color: rgba(148, 163, 184, 0.22); }
}

.lens-base-mode-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  margin: 0 0 12px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.15);
  font-size: 0.8rem;
  color: #b0b8c8;
  line-height: 1.45;
}

.lens-base-mode-notice .lens-notice-icon {
  flex-shrink: 0;
  font-size: 1.1em;
  margin-top: 1px;
}

/* ==========================================================================
   MedDex Lens — CT cine player and ECG summary
   The cine <video> sits in the same stage box as the still image, so the
   existing overlay layer, anatomy/pathology toggles and Smart Zoom transform
   apply to it unchanged.
   ========================================================================== */
.lens-v2 .lens-image-stage > video.lens-cine-video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100vw;
  max-height: calc(100dvh - var(--lens-peek));
  object-fit: contain;
  background: #000;
}
.lens-v2 .lens-image-stage > video.lens-cine-video.hidden { display: none; }
/* With a cine loaded the still <img> has no src; keep it out of the layout. */
.lens-v2.lens-cine-active .lens-image-stage > img { display: none; }

.lens-cine-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
.lens-cine-bar.hidden { display: none; }
.lens-cine-play {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* 44px accessible target — this is the primary cine control. */
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #0b1120;
  background: #38BDF8;
  transition: transform 0.15s ease, background 0.15s ease;
}
.lens-cine-play:hover { transform: scale(1.06); }
.lens-cine-play:focus-visible { outline: 2px solid #38BDF8; outline-offset: 2px; }
.lens-cine-play.playing { background: #7DD3FC; }
/* The scrubber stays visually slim but is a full 44px tall hit target, so it can
   actually be grabbed with a thumb. The visible track is painted on the
   runnable-track pseudo-element; the input itself is transparent padding.
   touch-action:none keeps a horizontal drag from being stolen as a page gesture. */
.lens-cine-scrubber {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  touch-action: none;
}
.lens-cine-scrubber::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.32);
}
.lens-cine-scrubber::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.32);
}
.lens-cine-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  /* Centre the thumb on the 6px track: (6 - 22) / 2. */
  margin-top: -8px;
  border: 2px solid #0b1120;
  border-radius: 50%;
  background: #38BDF8;
  box-shadow: 0 2px 8px rgba(2, 6, 23, 0.55);
  cursor: pointer;
  transition: transform 0.14s ease;
}
.lens-cine-scrubber:active::-webkit-slider-thumb { transform: scale(1.18); }
.lens-cine-scrubber::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 2px solid #0b1120;
  border-radius: 50%;
  background: #38BDF8;
  box-shadow: 0 2px 8px rgba(2, 6, 23, 0.55);
  cursor: pointer;
}
.lens-cine-scrubber:focus-visible { outline: 2px solid #38BDF8; outline-offset: 2px; }

/* Single-frame stepping, for when a drag is too coarse to land on the frame that
   actually demonstrates a finding. */
.lens-cine-step {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.5);
  color: rgba(226, 232, 240, 0.9);
  cursor: pointer;
}
.lens-cine-step:hover { border-color: rgba(56, 189, 248, 0.55); color: #e0f2fe; }
.lens-cine-step:active { transform: scale(0.93); }
.lens-cine-step:focus-visible { outline: 2px solid #38bdf8; outline-offset: 2px; }
.lens-cine-readout {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  letter-spacing: 0.01em;
  color: rgba(226, 232, 240, 0.78);
}

/* ---------------------------------------------------------------- quick jump
   One chip per abnormal finding. Horizontally scrollable so a dense study never
   pushes the report content down, with 44px targets for touch. */
.lens-jump {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 6px;
  min-width: 0;
}
.lens-jump-label {
  flex: 0 0 auto;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.9);
}
.lens-jump-track {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
  /* The sheet handles vertical drag; this strip owns horizontal panning. */
  touch-action: pan-x;
  scroll-snap-type: x proximity;
}
.lens-jump-track::-webkit-scrollbar { height: 4px; }
.lens-jump-track::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.35); border-radius: 999px; }
.lens-jump-chip {
  --lens-sev: #ff9f0a;
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  max-width: 200px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--lens-sev) 45%, transparent);
  background: color-mix(in srgb, var(--lens-sev) 12%, rgba(15, 23, 42, 0.72));
  color: #f1f5f9;
  font-size: 0.74rem;
  font-weight: 750;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}
.lens-jump-chip.sev-mild { --lens-sev: #facc15; }
.lens-jump-chip.sev-mod { --lens-sev: #ff9f0a; }
.lens-jump-chip.sev-sev { --lens-sev: #ff453a; }
.lens-jump-chip .lens-jump-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--lens-sev);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lens-sev) 22%, transparent);
}
.lens-jump-chip .lens-jump-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lens-jump-chip:hover { background: color-mix(in srgb, var(--lens-sev) 22%, rgba(15, 23, 42, 0.8)); }
.lens-jump-chip:active { transform: scale(0.96); }
.lens-jump-chip:focus-visible { outline: 2px solid var(--lens-sev); outline-offset: 2px; }
.lens-jump-chip.active {
  background: color-mix(in srgb, var(--lens-sev) 30%, rgba(15, 23, 42, 0.85));
  border-color: var(--lens-sev);
}
/* A finding whose overlay was withheld still gets a chip, marked so the user is
   not left tapping for a marker that will never appear. */
.lens-jump-chip.no-overlay { border-style: dashed; opacity: 0.82; }
.lens-jump-chip.no-overlay .lens-jump-dot { background: transparent; border: 2px dashed var(--lens-sev); }

/* ------------------------------------------------- on-device refinement */
.lens-v2 .lens-refine-btn.is-busy { opacity: 0.72; cursor: progress; }
.lens-v2 .lens-refine-btn.is-busy svg { animation: lens-refine-spin 900ms linear infinite; }
.lens-v2 .lens-refine-btn:disabled { opacity: 0.4; cursor: not-allowed; }
@keyframes lens-refine-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .lens-v2 .lens-refine-btn.is-busy svg { animation: none; }
}
/* A locally refined outline is drawn with a solid, slightly tighter stroke so it
   is visually distinguishable from the model's approximate box. */
.lens-hl.lens-hl-refined { stroke-dasharray: none; stroke-width: 1.6; }

/* -------------------------------------------------------------------- legend */
.lens-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 2px 0 10px;
  padding: 8px 11px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.42);
}
.lens-legend-item {
  --lens-sev: #94a3b8;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(226, 232, 240, 0.86);
}
.lens-legend-item i {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--lens-sev) 34%, transparent);
  border: 1.5px solid var(--lens-sev);
}
.lens-legend-item.lens-legend-anatomy { --lens-sev: #38bdf8; }
.lens-legend-item.lens-legend-anatomy i { border-radius: 50%; }
.lens-legend-item.sev-mild { --lens-sev: #facc15; }
.lens-legend-item.sev-mod { --lens-sev: #ff9f0a; }
.lens-legend-item.sev-sev { --lens-sev: #ff453a; }
.lens-legend-item.lens-legend-approx i { border-style: dashed; background: transparent; }

/* The report sheet only lightens when the app is explicitly in light theme, not
   merely because the OS prefers light — see .lens-sheet-panel above. These match
   that rule, otherwise light chips would sit inside a still-dark sheet. */
@media (prefers-color-scheme: light) {
  :root[data-theme="light"] .lens-jump-label { color: #475569; }
  :root[data-theme="light"] .lens-jump-chip {
    background: color-mix(in srgb, var(--lens-sev) 12%, #fff);
    border-color: color-mix(in srgb, var(--lens-sev) 55%, transparent);
    color: #0f172a;
  }
  :root[data-theme="light"] .lens-jump-chip:hover { background: color-mix(in srgb, var(--lens-sev) 22%, #fff); }
  :root[data-theme="light"] .lens-legend {
    background: rgba(241, 245, 249, 0.75);
    border-color: rgba(15, 23, 42, 0.12);
  }
  :root[data-theme="light"] .lens-legend-item { color: #1e293b; }
}

@media (prefers-reduced-motion: reduce) {
  .lens-jump-chip { transition: none; }
}

.lens-ecg-summary,
.lens-cine-summary {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.06);
}
/* Eight ECG measurements stacked vertically would push the findings off screen.
   This grid is scoped to the ECG block so the shared .lens-provenance lists used
   elsewhere in the report keep their existing appearance. */
.lens-ecg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px 14px;
  margin: 8px 0 0;
}
.lens-ecg-grid > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lens-ecg-grid dt {
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.66;
}
.lens-ecg-grid dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.lens-ecg-urgent {
  margin-top: 10px;
  padding: 8px 10px;
  border-left: 3px solid #F87171;
  border-radius: 6px;
  background: rgba(248, 113, 113, 0.1);
}
.lens-ecg-urgent strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #FCA5A5;
}

@media (prefers-color-scheme: light) {
  .lens-cine-readout { color: rgba(30, 41, 59, 0.78); }
}

/* "What the image shows" — the descriptive observation the diagnostic label
   rests on. Set apart from the interpretation lines so a reader can check the
   appearance against the conclusion. */
.lens-observation {
  border-left: 2px solid rgba(56, 189, 248, 0.55);
  padding-left: 10px;
  margin-left: 2px;
}
.lens-observation strong { color: #7dd3fc; }
@media (prefers-color-scheme: light) {
  :root[data-theme="light"] .lens-observation { border-left-color: rgba(2, 132, 199, 0.5); }
  :root[data-theme="light"] .lens-observation strong { color: #0369a1; }
}

/* Brief highlight on the page a deck search jumped to. */
.deck-pdf-page.deck-page-hit {
  outline: 3px solid #38bdf8;
  outline-offset: 2px;
  transition: outline-color 0.4s ease;
}
@media (prefers-reduced-motion: reduce) {
  .deck-pdf-page.deck-page-hit { transition: none; }
}
