:root {
  --bg: #0b0b0d;
  --fg: #f4f4f5;
  --muted: rgba(244,244,245,.68);
  --panel: rgba(10,10,12,.44);
  --line: rgba(255,255,255,.12);
  --accent: #ffffff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
body { overflow: hidden; }
.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }
.card {
  background: rgba(15,15,18,.86);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(0,0,0,.42);
}
#loginScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 20%, rgba(255,255,255,.08), transparent 36%), #09090b;
}
.login-card {
  width: min(92vw, 420px);
  padding: 24px;
}
.brand { font-size: clamp(28px, 6vw, 36px); font-weight: 700; letter-spacing: .08em; }
.sub { margin: 6px 0 20px; color: var(--muted); }
.login-form { display: grid; gap: 12px; }
.login-form input,
.login-form button {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  min-height: 54px;
  font-size: 16px;
}
.login-form input {
  padding: 0 16px;
  background: rgba(255,255,255,.06);
  color: var(--fg);
}
.login-form button {
  background: var(--fg);
  color: #111;
  font-weight: 700;
}
.status { margin: 12px 2px 0; font-size: 13px; }
.muted { color: var(--muted); }
.camera-shell {
  position: fixed; inset: 0; background: #000;
}
#video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000;
}
.topbar {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.top-left, .top-right {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.28);
  backdrop-filter: blur(10px);
  font-size: 11px;
  letter-spacing: .12em;
}
.ai-panel {
  position: absolute;
  top: calc(52px + var(--safe-top));
  right: 12px;
  width: min(44vw, 220px);
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(0,0,0,.24);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.10);
}
.ai-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 8px;
}
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 64px; height: 28px; padding: 0 10px;
  border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  background: rgba(255,255,255,.12);
}
.badge.watch { background: rgba(255,255,255,.16); }
.badge.good { background: rgba(255,255,255,.9); color: #111; }
.badge.now { background: rgba(255,255,255,1); color: #111; animation: pulse .9s ease-in-out infinite; }
.score { font-size: 12px; color: var(--muted); }
.ai-lines {
  display: grid; gap: 6px; font-size: 13px; line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
}
.frame-wrap {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.frame-guide {
  width: min(84vw, 520px);
  height: min(84vw * 1.25, 650px);
  border: 1px solid rgba(255,255,255,.62);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.12);
}
.frame-guide.ratio-1x1 { width: min(84vw, 520px); height: min(84vw, 520px); }
.frame-guide.ratio-4x5 { width: min(84vw, 520px); height: min(84vw * 1.25, 650px); }
.frame-guide.ratio-3x4 { width: min(82vw, 500px); height: min(82vw * 1.3333, 660px); }
.frame-guide.ratio-9x16 { width: min(72vw, 420px); height: min(72vw * 1.7778, 746px); }
.frame-guide.ratio-16x9 { width: min(88vw, 560px); height: min(88vw * .5625, 315px); }
.bottombar {
  position: absolute;
  left: 16px; right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 16px;
}
.mini-btn, .text-btn {
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.28);
  color: var(--fg);
  backdrop-filter: blur(10px);
}
.mini-btn {
  width: 56px; height: 56px; border-radius: 999px; font-size: 16px;
}
.mini-btn.strong { font-weight: 700; }
.mini-btn.analyzing {
  animation: pulseSoft 1.05s ease-in-out infinite;
}
.shutter {
  justify-self: center;
  width: 88px; height: 88px; border-radius: 999px;
  border: 4px solid rgba(255,255,255,.88);
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 0 0 8px rgba(255,255,255,.08);
  transition: transform .08s ease, box-shadow .18s ease, background .18s ease;
}
.shutter.good { box-shadow: inset 0 0 0 8px rgba(255,255,255,.18), 0 0 0 10px rgba(255,255,255,.08); }
.shutter.now { animation: pulse 0.9s ease-in-out infinite; }
.shutter.capturing {
  transform: scale(.94);
  background: rgba(255,255,255,.18);
}
.capture-flash {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.82);
  opacity: 0;
  pointer-events: none;
}
.capture-flash.show {
  animation: cameraFlash .28s ease-out;
}
.flash-notice {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: calc(124px + var(--safe-bottom));
  min-width: 100px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700; letter-spacing: .1em;
  background: rgba(255,255,255,.94); color: #111;
  opacity: 0; pointer-events: none;
}
.flash-notice.show { opacity: 1; }
.save-toast {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  top: calc(108px + var(--safe-top));
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,.58);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--fg);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
}
.save-toast.show {
  animation: toastInOut 1.2s ease;
}
.sheet {
  position: absolute; inset: 0; background: rgba(0,0,0,.2);
}
.sheet-card {
  position: absolute; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom));
  background: rgba(18,18,20,.96);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px;
  backdrop-filter: blur(16px);
}
.sheet-row { display: grid; gap: 10px; margin-bottom: 12px; }
.sheet-row.compact { grid-template-columns: repeat(3, 1fr); }
.sheet-row label { font-size: 12px; color: var(--muted); letter-spacing: .08em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button, .text-btn {
  min-height: 40px; border-radius: 999px; padding: 0 14px; font-size: 14px;
}
.chips button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--fg);
}
.chips button.active, .text-btn.primary {
  background: #fff; color: #111; border-color: rgba(255,255,255,.65);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,.35); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 12px rgba(255,255,255,0); }
}
@keyframes pulseSoft {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: .84; }
}
@keyframes cameraFlash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes toastInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  14%, 78% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}
@media (max-width: 420px) {
  .ai-panel { width: min(50vw, 180px); padding: 8px 10px; }
  .ai-lines { font-size: 12px; gap: 5px; }
  .top-left, .top-right { font-size: 10px; padding: 7px 9px; }
  .frame-guide.ratio-4x5 { width: min(82vw, 460px); height: min(82vw * 1.25, 575px); }
  .bottombar { gap: 12px; }
  .mini-btn { width: 52px; height: 52px; }
  .shutter { width: 82px; height: 82px; }
}
