* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; color: #fff; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
.hidden { display: none !important; }

#app { position: fixed; inset: 0; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }

#grid { position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% + .5px), transparent calc(33.33% + .5px),
      transparent calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% + .5px), transparent calc(66.66% + .5px)),
    linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% + .5px), transparent calc(33.33% + .5px),
      transparent calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% + .5px), transparent calc(66.66% + .5px)); }

/* Coaching overlay */
#coach { position: absolute; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 12px) 16px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,.75), rgba(0,0,0,0)); }
#instruction-row { display: flex; align-items: center; gap: 12px; }
#arrow { font-size: 40px; line-height: 1; min-width: 0; transition: transform .3s; }
#arrow:empty { display: none; }
#instruction { font-size: 26px; font-weight: 700; line-height: 1.15; text-shadow: 0 1px 4px rgba(0,0,0,.6); transition: color .3s; }
#coach.ready #instruction { color: #ffd60a; }
#coach.flash #instruction-row { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(1.06); } to { transform: scale(1); } }
#meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 13px; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.16); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.chip.good { background: rgba(48,209,88,.4); }
.chip.warn { background: rgba(255,159,10,.45); }
.chip.bad { background: rgba(255,69,58,.45); }
#status.busy::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #ffd60a; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
#lighting { margin-top: 8px; font-size: 15px; opacity: .95; }
#lighting::before { content: "☀︎ "; }
#tips { margin: 6px 0 0; padding-left: 18px; font-size: 14px; opacity: .85; }

/* Bottom controls */
#controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(env(safe-area-inset-bottom) + 16px);
  background: linear-gradient(to top, rgba(0,0,0,.7), rgba(0,0,0,0)); }
#lenses { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
#lenses button { min-width: 44px; height: 44px; padding: 0 10px; border-radius: 22px; font-size: 14px; font-weight: 600; background: rgba(0,0,0,.45); }
#lenses button.active { color: #ffd60a; background: rgba(0,0,0,.7); }
#lenses button.suggested { box-shadow: 0 0 0 2px #ffd60a; animation: blink 1.2s infinite; }
#shutter-row { display: flex; align-items: center; justify-content: space-between; max-width: 360px; margin: 0 auto; }
#shutter { width: 76px; height: 76px; border-radius: 50%; background: transparent; border: 4px solid #fff; padding: 4px; }
#shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
#shutter:active span { transform: scale(.88); }
#coach.ready ~ #controls #shutter { border-color: #ffd60a; }
.round { width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.18); font-size: 18px; }

/* Overlays */
.overlay { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; justify-content: center; gap: 14px;
  padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 24px); background: rgba(0,0,0,.88); overflow-y: auto; }
.overlay h1 { margin: 0; font-size: 36px; }
.overlay h2 { margin: 0; }
.overlay p { margin: 0; opacity: .85; line-height: 1.4; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field input, .field select { font: inherit; font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid #444; background: #1c1c1e; color: #fff; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.toggle input { width: 22px; height: 22px; }
.primary { background: #ffd60a; color: #000; font-weight: 700; padding: 14px; border-radius: 12px; font-size: 17px; }
.row { display: flex; gap: 12px; }
.row button { flex: 1; padding: 14px; border-radius: 12px; background: #2c2c2e; }
.error { color: #ff6961; }
.hint { font-size: 13px; text-align: center; }
#preview { justify-content: center; }
#preview img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 12px; }
#login { z-index: 20; }

/* Reference mode */
#ghost { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; opacity: .35; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#ai-note { margin-top: 6px; font-size: 15px; opacity: .92; }
#ai-note::before { content: "✦ "; color: #ffd60a; }
#ref-info { margin-top: 8px; font-size: 13px; opacity: .85; line-height: 1.35; }
#ref-bar { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
#ref-bar input { width: 140px; }
#ref-btn { position: relative; overflow: hidden; padding: 0; font-size: 22px; }
#ref-btn img { width: 100%; height: 100%; object-fit: cover; }
#ref-btn.active { box-shadow: 0 0 0 2px #ffd60a; }
button.chip { border: 0; color: #fff; font: inherit; font-size: 13px; }
#match.good { background: rgba(48,209,88,.55); }

/* Details panel */
#details { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,.55); }
#details #lighting:empty { display: none; }

/* Level */
#level { position: absolute; top: 50%; left: 50%; width: 120px; height: 0; transform: translate(-50%, -50%); pointer-events: none; }
#level span { display: block; height: 2px; background: rgba(255,255,255,.85); border-radius: 1px; transition: background .2s; }
#level.level span { background: #ffd60a; }
#level::before, #level::after { content: ""; position: absolute; top: -1px; width: 24px; height: 2px; background: rgba(255,255,255,.4); }
#level::before { left: -34px; } #level::after { right: -34px; }
