:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #0f1419;
  --muted: #536471;
  --line: #e1e5ea;
  --accent: #1d9bf0;
  --accent-ink: #ffffff;
  --err: #d0312d;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d10;
    --card: #16181c;
    --text: #e7e9ea;
    --muted: #8b98a5;
    --line: #2f3336;
    --err: #ff6b66;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-text-size-adjust: 100%;
}
main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}
header h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.sub { margin: 4px 0 20px; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.inapp {
  margin: 0 0 16px; padding: 14px; border-radius: 12px;
  background: #fff4d6; color: #3d2f00; border: 1px solid #f0d27a;
}
.inapp[hidden] { display: none; }
.inapp p { margin: 0 0 10px; }
.inapp .small { margin: 10px 0 0; font-size: 13px; }
.btn {
  display: block; text-align: center; text-decoration: none; font-weight: 700;
  padding: 13px 16px; border-radius: 12px; min-height: 48px;
}

form { display: grid; gap: 10px; }
.row { display: flex; gap: 8px; }
input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}
input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

button {
  font: inherit;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 48px;
  touch-action: manipulation;
}
button:disabled { opacity: 0.55; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); }
.ghost { background: transparent; color: var(--text); border-color: var(--line); }
#go { width: 100%; font-size: 17px; }

.opts { margin: 16px 0 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.opts summary { padding: 12px 14px; cursor: pointer; font-weight: 600; }
.opts .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 14px; }
@media (max-width: 420px) { .opts .grid { grid-template-columns: 1fr; } }
.opts label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.opts select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}
.hint { margin: 10px 14px 14px; font-size: 13px; color: var(--muted); }

#status { min-height: 24px; margin: 16px 0 8px; color: var(--muted); }
#status.err { color: var(--err); }

#results { display: grid; gap: 16px; }
.who { margin: 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.who b { color: var(--text); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.media { position: relative; background: #000; display: flex; justify-content: center; }
.media video { display: block; max-width: 100%; max-height: 60vh; }
.badge {
  position: absolute; left: 10px; top: 10px;
  background: rgba(0,0,0,.7); color: #fff; font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 6px;
}
.actions { display: flex; gap: 8px; padding: 12px; flex-wrap: wrap; }
.actions .saveGif { flex: 1 1 140px; }
.actions .ghost { flex: 0 1 auto; }
.progress { position: relative; margin: 0 12px 12px; height: 28px; border-radius: 8px; background: var(--bg); overflow: hidden; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); opacity: .25; transition: width .15s; }
.progress .ptext { position: relative; display: block; text-align: center; font-size: 13px; line-height: 28px; }

footer { margin-top: 32px; font-size: 13px; color: var(--muted); }
footer p { margin: 6px 0; }
.tip[hidden] { display: none; }
