:root {
  --bg: #0f1020;
  --bg2: #1a1b34;
  --card: #23244a;
  --card2: #2c2e5c;
  --accent: #7c5cff;
  --accent2: #ff5c9d;
  --gold: #ffcf5c;
  --text: #ececff;
  --muted: #a3a4c8;
  --good: #4fd1a1;
  --radius: 18px;
  --shadow: 0 10px 40px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #2a1c5a 0%, transparent 55%),
              radial-gradient(1000px 700px at 100% 0%, #4a1c46 0%, transparent 50%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { max-width: 860px; margin: 0 auto; padding: 24px 16px 64px; }

.hero { text-align: center; padding: 20px 0 8px; }
.hero-logo { width: 104px; height: 104px; object-fit: contain; filter: drop-shadow(0 6px 16px rgba(0,0,0,.35)); margin-bottom: 2px; }
.hero h1 { font-size: 2rem; margin: 0 0 8px; letter-spacing: -.5px; }
.hero .sub { color: var(--muted); line-height: 1.6; margin: 0; font-size: .95rem; }
.privacy { color: var(--good); font-size: .82rem; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.manual-btn { display: inline-block; padding: 10px 18px; border-radius: 30px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); color: var(--text);
  text-decoration: none; font-weight: 700; font-size: .9rem; transition: .15s; cursor: pointer; font-family: inherit; }
.manual-btn:hover:not(:disabled) { background: var(--accent); border-color: transparent; }
.manual-btn:disabled { opacity: .6; cursor: default; }

.credits-footer { margin-top: 26px; padding: 20px; text-align: center;
  border-top: 1px solid rgba(255,255,255,.08); }
.public-notice { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px; padding: 12px 16px; margin: 0 auto 18px; max-width: 560px;
  color: var(--muted); font-size: .84rem; line-height: 1.7; }
.public-notice a { color: var(--accent2); text-decoration: none; font-weight: 700; }
.public-notice a:hover { text-decoration: underline; }
.credits-title { font-weight: 800; color: var(--gold); margin-bottom: 12px; font-size: .95rem; }
.credits-grid { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px 22px; }
.credits-grid > div { display: flex; flex-direction: column; gap: 2px; }
.c-role { font-size: .72rem; color: var(--muted); }
.c-name { font-weight: 700; font-size: .92rem; }
.credits-copy { margin-top: 14px; color: var(--muted); font-size: .76rem; }

.panel {
  background: linear-gradient(180deg, var(--bg2), var(--card));
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-top: 18px;
}
.hidden { display: none !important; }

.loading { text-align: center; padding: 48px 20px; }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 16px;
  border: 4px solid rgba(255,255,255,.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.capture-grid { display: grid; grid-template-columns: 1fr 240px; gap: 20px; }
@media (max-width: 680px){ .capture-grid { grid-template-columns: 1fr; } }

.preview-wrap {
  position: relative; width: 100%; aspect-ratio: 1/1;
  background: #14152b; border-radius: 14px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
#preview, #video { width: 100%; height: 100%; object-fit: cover; display: none; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.placeholder { text-align: center; color: var(--muted); }
.placeholder span { font-size: 3rem; display: block; margin-bottom: 8px; }

.capture-controls { display: flex; flex-direction: column; gap: 10px; }
.btn {
  appearance: none; border: 1px solid rgba(255,255,255,.12);
  background: var(--card2); color: var(--text);
  padding: 12px 14px; border-radius: 12px; font-size: .95rem;
  cursor: pointer; text-align: center; transition: transform .08s, filter .15s;
  font-weight: 600;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b8bff); border: none; }
.btn.accent { background: linear-gradient(135deg, var(--accent2), var(--gold)); border: none; color: #26123a; }
.hint { color: var(--muted); font-size: .8rem; margin: 4px 0 0; line-height: 1.5; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  flex: 1; min-width: 100px; padding: 10px; border-radius: 12px; cursor: pointer;
  background: transparent; border: 1px solid rgba(255,255,255,.12); color: var(--muted);
  font-weight: 700; font-size: .92rem; transition: .15s;
}
.tab.active { background: var(--accent); border-color: transparent; color: #fff; }

.tab-pane { display: none; animation: fade .3s; }
.tab-pane.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

.result-hero { text-align: center; margin-bottom: 18px; }
.result-emoji { font-size: 3.4rem; }
.result-title { font-size: 1.6rem; font-weight: 800; margin: 6px 0 2px; }
.result-tag { color: var(--gold); font-weight: 700; }

.bar-row { display: grid; grid-template-columns: 92px 1fr 48px; align-items: center; gap: 10px; margin: 8px 0; }
.bar-label { font-size: .9rem; color: var(--muted); }
.bar-track { background: rgba(255,255,255,.08); height: 12px; border-radius: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.bar-val { font-size: .82rem; text-align: right; color: var(--muted); }

.read-card {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px; padding: 14px 16px; margin: 10px 0;
}
.read-card h4 { margin: 0 0 6px; font-size: 1rem; color: var(--gold); }
.read-card p { margin: 0; line-height: 1.65; color: var(--text); font-size: .93rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip { background: var(--card2); border-radius: 20px; padding: 6px 14px; font-size: .85rem; border: 1px solid rgba(255,255,255,.1); }

.celeb-list { display: flex; flex-direction: column; gap: 10px; }
.celeb-row { display: grid; grid-template-columns: 56px 1fr 60px; align-items: center; gap: 12px;
  background: rgba(255,255,255,.04); border-radius: 12px; padding: 8px 12px; }
.celeb-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; }
.celeb-thumb-none { width: 56px; height: 56px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--card2); font-size: 1.4rem; }
.celeb-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.celeb-name { font-weight: 700; }
.celeb-credit { font-size: .74rem; color: var(--muted); text-decoration: none; }
.celeb-credit:hover { color: var(--accent); text-decoration: underline; }
.celeb-score { text-align: right; font-weight: 800; color: var(--good); }

.notice { background: rgba(255,207,92,.1); border: 1px solid rgba(255,207,92,.3);
  border-radius: 12px; padding: 14px 16px; color: #ffe6a8; line-height: 1.6; font-size: .9rem; }
.notice code { background: rgba(0,0,0,.3); padding: 2px 6px; border-radius: 6px; }

.result-actions { display: flex; gap: 10px; margin-top: 18px; }
.result-actions .btn { flex: 1; }
.disclaimer { text-align: center; color: var(--muted); font-size: .78rem; margin: 14px 0 0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #000; color: #fff; padding: 12px 20px; border-radius: 30px; opacity: 0;
  transition: opacity .3s; pointer-events: none; z-index: 50; font-size: .9rem; }
.toast.show { opacity: .92; }
