/* PhotoCoach — camera UI. Deliberately dark, single-theme (a viewfinder). */
:root {
  --bg: #0B0D0E;
  --surface: #16191B;
  --line: #2A2F32;
  --ink: #F2F4F5;
  --muted: #9AA4A8;
  --accent: #F5B841;        /* focus-box amber */
  --good: #4CC38A;
  --warn: #E5766B;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}

.screen { position: fixed; inset: 0; }

/* ---- start screen ---- */
#startScreen { display: grid; place-items: center; background: var(--bg); z-index: 30; }
.start-inner { text-align: center; padding: 24px; max-width: 340px; }
.start-logo { width: 84px; height: 84px; border-radius: 20px; }
.start-inner h1 { font-size: 28px; margin: 14px 0 4px; letter-spacing: -0.02em; }
.tagline { color: var(--muted); margin: 0 0 26px; line-height: 1.45; }
.start-error { color: var(--warn); line-height: 1.4; }
.start-hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 22px; }

.btn-primary {
  background: var(--accent); color: #171204; border: 0; border-radius: 12px;
  font-size: 17px; font-weight: 600; padding: 14px 26px; width: 100%; cursor: pointer;
}
.btn-secondary {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; font-size: 15px; font-weight: 500; padding: 12px 16px; cursor: pointer;
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.97); }

/* ---- camera stage ---- */
#stage { position: absolute; inset: 0; background: #000; }
#video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
}
#video.mirrored { transform: scaleX(-1); }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.bar {
  position: absolute; left: 0; right: 0; display: flex; align-items: center;
  gap: 10px; padding: 10px 14px; z-index: 5;
}
#topBar { top: 0; padding-top: calc(10px + var(--safe-top)); }
.top-spacer { flex: 1; }
#bottomBar {
  bottom: 0; padding-bottom: calc(16px + var(--safe-bottom));
  justify-content: space-between;
}

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(14, 16, 17, 0.55); color: var(--ink); font-size: 19px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center;
}
.icon-btn[aria-pressed="true"], .icon-btn.active { background: var(--accent); color: #171204; }

/* shutter */
.shutter-wrap { position: absolute; left: 50%; transform: translateX(-50%); }
#btnShutter {
  width: 74px; height: 74px; border-radius: 50%; cursor: pointer;
  border: 4px solid #FFFFFF; background: rgba(255,255,255,0.25);
}
#btnShutter:active { background: #FFFFFF; }
#btnShutter.smart-armed { border-color: var(--accent); }

.thumb-btn {
  width: 46px; height: 46px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); overflow: hidden; padding: 0; cursor: pointer;
}
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; }

.mode-col { display: flex; flex-direction: column; gap: 8px; }
.pill-btn {
  border: 1px solid rgba(255,255,255,0.4); background: rgba(14,16,17,0.45);
  color: var(--ink); border-radius: 999px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; padding: 7px 12px; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.pill-btn[aria-pressed="true"] { background: var(--accent); color: #171204; border-color: var(--accent); }

/* score ring */
#scoreWrap {
  position: absolute; right: 14px; top: calc(66px + var(--safe-top)); z-index: 5;
  width: 52px; height: 52px;
}
#scoreWrap svg { transform: rotate(-90deg); }
.ring-bg { fill: rgba(14,16,17,0.5); stroke: rgba(255,255,255,0.25); stroke-width: 3.5; }
.ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round;
  stroke-dasharray: 119.4; stroke-dashoffset: 119.4;
  transition: stroke-dashoffset 0.4s, stroke 0.4s;
}
#scoreNum {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* hint pill */
#hintPill {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(128px + var(--safe-bottom)); z-index: 5; max-width: 84%;
  background: rgba(14,16,17,0.72); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px; padding: 9px 18px; text-align: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 14.5px; font-weight: 500;
  animation: hintIn 0.25s ease;
}
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* countdown */
#countdown {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 6;
  font-size: 96px; font-weight: 800; color: #fff;
  text-shadow: 0 2px 24px rgba(0,0,0,0.6); pointer-events: none;
}

/* zoom */
#zoomSlider {
  position: absolute; right: 8px; top: 50%; z-index: 5;
  width: 130px; transform: translateY(-50%) rotate(-90deg); transform-origin: center;
  accent-color: var(--accent);
}

/* flash + toast */
#flash {
  position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 40;
}
#flash.go { animation: flashAnim 0.28s ease; }
@keyframes flashAnim { 0% { opacity: 0.85; } 100% { opacity: 0; } }
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(120px + var(--safe-bottom)); z-index: 50;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 10px 18px; font-size: 14px; max-width: 86%;
}

/* ---- sheets ---- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 86%;
  background: var(--surface); border-radius: 18px 18px 0 0; z-index: 20;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column;
  animation: sheetIn 0.25s ease;
}
@keyframes sheetIn { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 8px;
}
.sheet h2 { margin: 0; font-size: 18px; }
.sheet-close { background: var(--bg); font-size: 15px; }
.sheet-body { padding: 6px 18px calc(20px + var(--safe-bottom)); overflow-y: auto; }

#heroImg { width: 100%; border-radius: 12px; display: block; }
.hero-why { color: var(--muted); font-size: 13.5px; margin: 10px 2px; }
#altRow { display: flex; gap: 8px; margin: 4px 0 14px; overflow-x: auto; }
#altRow img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 8px;
  border: 2px solid transparent; flex-shrink: 0;
}
#altRow img.sel { border-color: var(--accent); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn-primary { flex: 1.4; width: auto; }
.btn-row .btn-secondary { flex: 1; }

.setting {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 2px; border-bottom: 1px solid var(--line); font-size: 15.5px;
}
.setting input { width: 22px; height: 22px; accent-color: var(--accent); }
.setting-note { padding: 14px 2px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.setting-note p { margin: 0 0 8px; }
.muted { color: var(--muted); }

/* sun sheet */
.sun-row {
  display: flex; justify-content: space-between; padding: 11px 2px;
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.sun-row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.sun-note { color: var(--muted); font-size: 13px; margin-top: 12px; line-height: 1.5; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
