/* ============================================================================
   Lenscore — interface
   Dark, low-chrome, thumb-first. Everything sits over the live camera feed.
   ========================================================================== */

:root {
  --bg: #08080a;
  --ink: #f4f2ee;
  --ink-dim: rgba(244, 242, 238, 0.62);
  --ink-faint: rgba(244, 242, 238, 0.38);
  --amber: #f4b854;
  --amber-deep: #d6842c;
  --line: rgba(255, 255, 255, 0.10);
  --glass: rgba(18, 18, 21, 0.62);
  --glass-solid: #101013;
  --danger: #ff6b5e;
  --score-color: var(--amber);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { display: block; }

#app { position: fixed; inset: 0; overflow: hidden; }

/* ───────────────────────────── views ───────────────────────────────────── */

.view { position: absolute; inset: 0; }
.view[hidden] { display: none; }

.view--camera { background: #000; }

.view--sheet {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 20;
  animation: sheet-in 0.34s var(--ease);
}

@keyframes sheet-in {
  from { transform: translateY(18px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ───────────────────────────── camera ──────────────────────────────────── */

#cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  transition: opacity 0.4s ease;
}

#cam.mirrored { transform: scaleX(-1); }

.guide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.scrim {
  position: absolute;
  left: 0; right: 0;
  pointer-events: none;
}
.scrim--top    { top: 0;    height: 34%; background: linear-gradient(to bottom, rgba(0,0,0,0.66), rgba(0,0,0,0)); }
.scrim--bottom { bottom: 0; height: 30%; background: linear-gradient(to top,    rgba(0,0,0,0.78), rgba(0,0,0,0)); }

/* ───────────────────────────── HUD top ─────────────────────────────────── */

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: calc(var(--safe-t) + 14px) 18px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.hud-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  pointer-events: auto;
}

.brand-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 12px var(--amber);
}

.icon-btn--hud {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.icon-btn--hud svg { width: 18px; height: 18px; }

.install {
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: rgba(244, 184, 84, 0.16);
  border: 1px solid rgba(244, 184, 84, 0.42);
}

/* score ring */
.score-cluster {
  position: relative;
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
}

.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.13);
  stroke-width: 5;
}

.ring-fill {
  fill: none;
  stroke: var(--score-color);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.28s var(--ease), stroke 0.4s ease;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--score-color) 55%, transparent));
}

.score-readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.score {
  font-size: 44px;
  font-weight: 300;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.grade {
  margin-top: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--score-color);
}

.hint {
  max-width: 300px;
  min-height: 18px;
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-dim);
  transition: opacity 0.25s ease;
}

/* ───────────────────────────── metric strip ────────────────────────────── */

.metric-strip {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--safe-b) + 128px);
  display: flex;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
.metric-strip::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-width: 76px;
  padding: 8px 10px 9px;
  border-radius: 13px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  transition: border-color 0.3s ease;
}

.chip-label {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.chip-val {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.chip-bar {
  margin-top: 6px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.chip-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--score-color);
  transition: width 0.3s var(--ease), background 0.4s ease;
}

.chip.is-low { border-color: rgba(255, 107, 94, 0.34); }
.chip.is-low .chip-val { color: #ffb3ac; }

/* ───────────────────────────── HUD bottom ──────────────────────────────── */

.hud-bottom {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--safe-b) + 22px);
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.round-btn {
  width: 52px; height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.16s var(--ease), background 0.2s ease;
}
.round-btn:active { transform: scale(0.92); background: rgba(40, 40, 46, 0.8); }
.round-btn svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shutter {
  position: relative;
  width: 78px; height: 78px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: transform 0.14s var(--ease);
}
.shutter:active { transform: scale(0.93); }

.shutter-core {
  width: 62px; height: 62px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 6px 22px rgba(0, 0, 0, 0.45);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.shutter-ring {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  fill: none;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 2.5;
}

.shutter.is-hot .shutter-core {
  background: var(--amber);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 0 26px rgba(244, 184, 84, 0.55);
}
.shutter.is-hot .shutter-ring { stroke: rgba(244, 184, 84, 0.85); }

/* auto-capture countdown */
.shutter-ring circle {
  stroke-dasharray: 289.03;
  stroke-dashoffset: 289.03;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.12s linear;
}

/* ───────────────────────────── flash / toast ───────────────────────────── */

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.flash.go { animation: flash 0.42s ease-out; }
@keyframes flash {
  0%   { opacity: 0.85; }
  100% { opacity: 0; }
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 214px);
  transform: translate(-50%, 8px);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  background: rgba(20, 20, 24, 0.9);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s var(--ease);
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ───────────────────────────── permission panel ────────────────────────── */

.perm {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 6, 8, 0.94);
  backdrop-filter: blur(8px);
}
.perm[hidden] { display: none; }

.perm-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.perm-icon {
  width: 56px; height: 56px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(244, 184, 84, 0.12);
  border: 1px solid rgba(244, 184, 84, 0.28);
}
.perm-icon svg {
  width: 26px; height: 26px;
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.perm-card h2 {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}

.perm-card p {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  margin-bottom: 20px;
}

.perm-note {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* ───────────────────────────── buttons ─────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: transform 0.14s var(--ease), background 0.2s ease;
}
.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #17120a;
  font-weight: 600;
}

.btn--ghost { background: transparent; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  transition: background 0.2s ease;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.08); }
.icon-btn svg {
  width: 21px; height: 21px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn--danger svg { stroke: var(--danger); }

.text-btn {
  font-size: 13px;
  font-weight: 500;
  color: var(--amber);
  padding: 8px 4px;
}

/* ───────────────────────────── sheet chrome ────────────────────────────── */

.sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(var(--safe-t) + 10px) 12px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.sheet-head h1 {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.count {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

/* ───────────────────────────── gallery ─────────────────────────────────── */

.shot-grid {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px 3px calc(var(--safe-b) + 20px);
  align-content: start;
}

.shot {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 4px;
  background: #141417;
}
.shot img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s var(--ease);
}
.shot:active img { transform: scale(1.04); }

.shot-score {
  position: absolute;
  left: 5px; bottom: 5px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(8, 8, 10, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--c, var(--amber));
}

.empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px 30px calc(var(--safe-b) + 60px);
  text-align: center;
  color: var(--ink-faint);
}
.empty[hidden] { display: none; }
.empty svg {
  width: 34px; height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: 10px;
  opacity: 0.7;
}
.empty p { font-size: 15px; color: var(--ink-dim); }
.empty span { font-size: 12.5px; line-height: 1.5; max-width: 260px; }

/* ───────────────────────────── detail ──────────────────────────────────── */

.view--detail { background: var(--bg); }

.detail-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-b) + 24px);
}

.detail-media {
  position: relative;
  background: #000;
}
.detail-media img {
  width: 100%;
  max-height: 56vh;
  object-fit: contain;
  display: block;
}

.detail-badge {
  position: absolute;
  right: 12px; bottom: 12px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 12px;
  background: rgba(8, 8, 10, 0.78);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.detail-score {
  font-size: 24px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.detail-grade {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--score-color);
}

.detail-metrics {
  padding: 18px 18px 4px;
  display: grid;
  gap: 11px;
}

.dm {
  display: grid;
  grid-template-columns: 84px 1fr 30px;
  align-items: center;
  gap: 10px;
}
.dm-label {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}
.dm-bar {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.dm-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--c, var(--amber));
}
.dm-val {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
}

.detail-actions {
  display: flex;
  gap: 10px;
  padding: 18px;
}

/* ───────────────────────────── settings ────────────────────────────────── */

.settings-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px calc(var(--safe-b) + 40px);
}

.section-title {
  margin: 26px 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.section-note {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-dim);
  margin-bottom: 12px;
}
.section-note.dim { color: var(--ink-faint); margin-top: 14px; }

.weight-list { display: grid; gap: 14px; }

.weight {
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 4px 10px;
  align-items: baseline;
}
.weight-name {
  font-size: 13px;
  color: var(--ink);
}
.weight-val {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--amber);
}
.weight input[type="range"] { grid-column: 1 / -1; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
}
input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -6.5px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(244, 184, 84, 0.14);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--amber);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13.5px;
}
.row--slider { flex-direction: column; align-items: stretch; gap: 6px; }
.row--slider[hidden] { display: none; }
.row--slider span { display: flex; justify-content: space-between; }
.row--slider b { color: var(--amber); font-variant-numeric: tabular-nums; }

/* switch */
.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 44px; height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.22s ease;
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.22s var(--ease);
}
.switch:checked { background: var(--amber); }
.switch:checked::after { transform: translateX(18px); }

/* ───────────────────────────── responsive ──────────────────────────────── */

@media (min-width: 620px) {
  .shot-grid { grid-template-columns: repeat(4, 1fr); }
  .view--sheet { max-width: 520px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .detail-media img { max-height: 62vh; }
}

@media (min-width: 900px) {
  .shot-grid { grid-template-columns: repeat(5, 1fr); }
}

/* short viewports (landscape phones) */
@media (max-height: 520px) {
  .score-cluster { width: 96px; height: 96px; }
  .score { font-size: 32px; }
  .metric-strip { bottom: calc(var(--safe-b) + 104px); }
  .hud-bottom { bottom: calc(var(--safe-b) + 10px); }
  .shutter { width: 62px; height: 62px; }
  .shutter-core { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
